IP address is a unique identifier for a computer on a network. It is obtained by asking the DNS server for the name of the computer’s hostname. To get an IP address from a DNS hostname, you can use the GetIpAddress() function. The GetIpAddress() function takes two arguments: the computer’s hostname and an IP address. The first argument is the name of the DNS server, and the second argument is an IP address. The GetIpAddress() function will return an IP address if it finds it in the DNS database, or NULL if it doesn’t find it.
First you’ll add the System.Net namespace to your using section:
Example of code to get address from hostname:
This was tested in C# 2.0.