using System; using System.Net;
namespace Project1 { /// <summary> /// /// </summary> public 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; } } public ResolveDNS() { // // TOD 在此处添加构造函数逻辑 // } } class TestApp { public static void Main() { ResolveDNS resolverl = new ResolveDNS(); resolverl.Resolve("www.sina.com.cn"); int n = resolverl.IPLength; Console.WriteLine("Get the IP Address of the host"); Console.WriteLine(); for ( int i = 0; i < n;i++) { Console.WriteLine(resolverl[i]); } } } } 以上程序在vs。net2003中不通过,说 类型或命名空间名称“Net”在类或命名空间“System”中不存在(是否缺少程序集引用?) 反而在用命令csc filename.cs没有一点问题,真的好奇怪?望高手指点!