using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
namespace ConsoleApplication8
...{
class Program
...{
static void Main(string[] args)
...{
if (args.Length != 1)
...{
Console.WriteLine("Usage:Dns");
Console.ReadLine();
return;
}
IPHostEntry iphost = Dns.GetHostEntry(args[0]);
Console.WriteLine("Host:{0}",&nbs
p;iphost.HostName);
if (iphost.Aliases.Length > 0)
...{
Console.WriteLine(" Aliases");
foreach (string alias in iphost.Aliases)
...{
Console.WriteLine(alias);
}
}
Console.WriteLine(" Address(es):");
foreach (IPAddress address in iphost.AddressList)
...{
Console.WriteLine("Address:{0}", address.ToString());
}
}
}
} 最後在程序的屬性中設計debug的命令參數 如:www.baidu.com 就可以查找對方的IP