/// <summary> /// Returns a string that represents the current <see cref="NetworkAddress" />. /// </summary> /// <returns> /// A string that represents the current <see cref="NetworkAddress" />. /// </returns> public override string ToString() { if (Equals(LocalSubnet)) { return("LocalSubnet"); } if (SubnetMask.Equals(IPAddress.None)) { return(Address.ToString()); } return($"{Address}/{SubnetMask}"); }
public override bool Equals(object obj) { Adapter a; try { a = (Adapter)obj; } catch (InvalidCastException) { return(false); } if (MyMACAddress == null) { if (a.MyMACAddress != null) { return(false); } } else if (!MyMACAddress.Equals(a.MyMACAddress)) { return(false); } if (LocalIP == null) { if (a.LocalIP != null) { return(false); } } else if (!LocalIP.Equals(a.LocalIP)) { return(false); } if (SubnetMask == null) { if (a.SubnetMask != null) { return(false); } } else if (!SubnetMask.Equals(a.SubnetMask)) { return(false); } if (DefaultGateway == null) { if (a.DefaultGateway != null) { return(false); } } else if (!DefaultGateway.Equals(a.DefaultGateway)) { return(false); } if (DNS == null) { if (a.DNS != null) { return(false); } } else if (!DNS.Equals(a.DNS)) { return(false); } if ((Name == a.Name) && (OtherEndID == a.OtherEndID) && (Connected == a.Connected) && (Associated == a.Associated)) { return(true); } return(false); }
/// <summary> /// Compares two network address. /// </summary> /// <returns> /// <see langword="true" /> if the two network address are equal; otherwise, <see langword="false" />. /// </returns> /// <param name="comparand">An <see cref="NetworkAddress" /> instance to compare to the current instance. </param> protected bool Equals(NetworkAddress comparand) { return(Address.Equals(comparand.Address) && SubnetMask.Equals(comparand.SubnetMask)); }