Mega Code Archive

 
Categories / C# Book / 08 Net
 

0603 IPAddress object to domain name

GetHostEntry accepts an IPAddress object, so you can specify an IP address as a byte array: using System; using System.Net; using System.Threading; using System.IO; using System.Text; class ThreadTest { static void Main() { IPAddress address = new IPAddress(new byte[] { 199, 181, 132, 250 }); IPHostEntry entry = Dns.GetHostEntry(address); Console.WriteLine(entry.HostName); } } The output: tienda.espndeportes.com