martes, 8 de septiembre de 2009

c# hostname2IP

using  System.Net;
namespace hostname2IP
{
class Program
{
static void Main(string[] args)
{
//string hostName = Dns.GetHostName();

string hostName = "www.google.com";
//string hostName = "127.0.0.1";

Console.WriteLine("Host Name = " + hostName);
//IPHostEntry local = Dns.GetHostByName(hostName);
IPHostEntry local2 = Dns.GetHostEntry(hostName);
foreach (IPAddress ipaddress in local2.AddressList)
{
Console.WriteLine("IPAddress = " + ipaddress.ToString());
}

Console.Write("\nPress Enter..");
Console.ReadLine();
}
}
}

No hay comentarios:

Publicar un comentario