示例#1
0
        /// <summary>
        /// Converts a string containing an IP address in the standard dotted
        /// format to an IPv4Address object.
        /// </summary>
        ///
        /// <param name="IPAddress">
        /// The IP address in the standard dotted format.
        /// </param>
        ///
        /// <returns>
        /// A converted IPv4Address object.
        /// </returns>
        ///
        /// <throws>
        /// Format Exception
        /// Argument Out of Range Exception
        /// </throws>
        ///
        public static IPv4Address Parse(string IPAddress)
        {
            IPv4Address newAddress = IPv4Address.Empty;

            if (!string.IsNullOrEmpty(IPAddress))
            {
                newAddress.ConvertStringToQuadrants(IPAddress);
            }

            return(newAddress);
        }
示例#2
0
        /// <summary>
        /// Determines if the quadrants of this object match the quadrants of
        /// the passed object.
        /// </summary>
        ///
        /// <param name="OtherAddress">
        /// The IPv4Address to check for equality.
        /// </param>
        ///
        /// <returns>
        /// True if the quadrants of the passed object equal the current object's
        /// quadrant values.
        /// </returns>
        ///
        public bool Equals(IPv4Address OtherAddress)
        {
            bool isEqual = OtherAddress != null;

            if (isEqual)
            {
                for (int idx = 0; idx < NUM_QUADRANTS; idx++)
                {
                    if (Quadrants[idx] != OtherAddress.Quadrants[idx])
                    {
                        isEqual = false;
                        break;
                    }
                }
            }

            return(isEqual);
        }