IPAddress address1 = IPAddress.Parse("192.168.0.1"); IPAddress address2 = IPAddress.Parse("192.168.0.1"); if (address1.Equals(address2)) { Console.WriteLine("The IP addresses are equal."); } else { Console.WriteLine("The IP addresses are not equal."); }
IPAddress address1 = IPAddress.Parse("192.168.0.1"); IPAddress address2 = IPAddress.Parse("192.168.0.2"); if (address1.Equals(address2)) { Console.WriteLine("The IP addresses are equal."); } else { Console.WriteLine("The IP addresses are not equal."); }In this example, we create two IP addresses (`address1` and `address2`) with different values. We then call the `Equals` method on `address1` with `address2` as the parameter. Since the two IP addresses are not equal, the method returns `false` and we output a message indicating that the IP addresses are not equal. Package/Library: `System.Net`