How To Convert an IP Address To Hostname

You have an IP address that you need to resolve into a hostname.

Use the Dns.GetHostEntry method to get the hostname for an IP address. In the following code, an IP address is resolved, and the hostname is accessible from the HostName property of the IPHostEntry:

 using System;
using System.Net;

// Use the Dns class to resolve the address.
IPHostEntry iphost = Dns.GetHostEntry("");

// HostName property holds the hostname.
string hostName = iphost.HostName;

// Print out name.

Post a Comment


Close Menu