System.Net IPAddress is a class used to represent IP addresses. It can be used to parse, validate and manipulate IP addresses.
Example code using IPAddress package library:
1. Creating an IPAddress object:
var addr = IPAddress.Parse("192.168.0.1");
2. Validating an IP address:
var isValid = IPAddress.TryParse("192.168.0.1", out var ipAddress);
3. Getting the host name for an IP address:
var ipAddress = IPAddress.Parse("192.168.0.1"); var hostName = Dns.GetHostEntry(ipAddress).HostName;
4. Obtaining a string representation of an IP address:
var ipAddress = IPAddress.Parse("192.168.0.1"); var ipAddressString = ipAddress.ToString();
The package library for this example is System.Net.
C# (CSharp) System.Net IPAddress - 60 examples found. These are the top rated real world C# (CSharp) examples of System.Net.IPAddress extracted from open source projects. You can rate examples to help us improve the quality of examples.