C#提示Dns.Resolve()已过期的解决方法(经过域名查询IP的完整代码)

解决方法:

 把Dns.Resolve()改为Dns.GetHostEntry()便可code

C#经过域名查询IP的完整代码以下:

IPHostEntry hostEntry = Dns.GetHostEntry(strDomain);           
IPEndPoint ipEndPoint = new IPEndPoint(hostEntry.AddressList[0], 0);
string ipAddress = ipEndPoint.Address.ToString();
MessageBox.Show("IP地址:"+ipAddress);