Mega Code Archive

 
Categories / C# Book / 08 Net
 

0601 Using DNS

The static Dns class encapsulates the Domain Name Service. Domain Name Service converts between a raw IP address, such as 66.15.12.87, and a human-friendly domain name. The GetHostAddresses method converts from domain name to IP address (or addresses): using System; using System.Net; using System.Threading; using System.IO; using System.Text; class ThreadTest { static void Main() { foreach (IPAddress a in Dns.GetHostAddresses("abc.com")) Console.WriteLine(a.ToString()); } } The output: 199.181.132.250