代码:
using System;
using System.Net;
public class ResolveDNS
{
IPAddress[] m_arrIPs;
public void Resolve(string strHost)
{
IPHostEntry iphe = DNS.GetHostByName(strHost); 
m_arrIPs = iphe.AddressList;
}
public IPAddress this[int nIndex]
{
get
{
return m_arrIPs[nIndex];
}
}
public int Count
{
get
{
return m_arrIPs.Length;
}
}
}
class DNSResolverApp
{
public static void Main()
{
ResolveDNS myDNSResolver = new ResolveDNS();
myDNSResolver.Resolve("http://www.microsoft.com"); int nCount = myDNSResolver.Count;
Console.WriteLine("Found {0} IP's for hostname", nCount);
for (int i=0; i < nCount; i++)
Console.WriteLine(myDNSResolver[i]);

}