Resolve an IP address to an IPHostEntry instance in CSharp
Description
The following code shows how to resolve an IP address to an IPHostEntry instance.
Example
//from w w w .j a va 2s. c om
using System;
using System.Net;
using System.Net.Sockets;
public class Example
{
public static void Main()
{
IPHostEntry host = Dns.GetHostEntry("google.com");
Console.WriteLine("GetHostEntry({0}) returns:", host);
foreach (IPAddress ip in host.AddressList)
{
Console.WriteLine(" {0}", ip);
}
}
}
The code above generates the following result.