//filename:ResolveDNSApp.cs
using System;
using System.Net;class ResolveDNS
{
IPAdress[] m_arrayIPs;
public void Resolve(string s_host)
{
IPHostEntry ip = DNS.GetHostByName(s_host);
m_arrayIPs = ip.AddressList;
}
public IPAddress this[int nIndex]
{
get
{
return m_arrayIPs[nIndex];
}
}
public int IPLength
{
get
{
return m_arrayIPs.Length;
}
}
}class ResolveDNSApp
{
public static void Main()
{
ResolveDNS resolver = new ResolveDNS();
resolver.Resolve(www.sohu.com);
int n = resolver.IPLength;
Console.WriteLine("Ger the IP Address of host:");
Console.WriteLine();
for(int i = 0; i < n; i++)
{
Console.WriteLine(resolver[i]);
}
}
}我用csc命令提示:找不到类型或者命名空间名称“IPAdress”(是否缺少 using 指令或程序集引用)
CSDN文档指出IPAdress类在System.Net空间中啊
知道的人发句话!!!!
说一下是怎么回事,怎么解决啊!??、
-------------MSDN文档中也只有IPAddress而没有IPAdress
没时间给你传了,自己到网上找吧
using System;
using System.Net;class ResolveDNS
{
IPAddress[] m_arrayIPs;
public void Resolve(string s_host)
{
IPHostEntry ip = Dns.GetHostByName(s_host);
m_arrayIPs = ip.AddressList;
}
public IPAddress this[int nIndex]
{
get
{
return m_arrayIPs[nIndex];
}
}
public int IPLength
{
get
{
return m_arrayIPs.Length;
}
}
}class ResolveDNSApp
{
public static void Main()
{
ResolveDNS resolver = new ResolveDNS();
resolver.Resolve("www.sohu.com");
int n = resolver.IPLength;
Console.WriteLine("Get the IP Address of host:");
Console.WriteLine();
for(int i = 0; i < n; i++)
{
Console.WriteLine(resolver[i]);
}
}
}