コード例 #1
0
        /// <summary>
        /// Converts IPAddress to valid range that starts from 1 and ends with 254
        ///
        /// For example: If '192.168.0.34' was passed, method will return a string '192.168.0.1-254'
        /// </summary>
        /// <param name="addr">IPAddress to convert</param>
        /// <returns>Valid range from 1 to 254</returns>
        public static string ConvertIPAddressToDefaultRange(IPAddress addr)
        {
            // Change last byte of IPAddress to 1
            var ip = addr.ChangeByteAtIndex(1, 3);

            // Return range e.g. "192.168.0.1-254"
            return($"{ip}-254");
        }