//根据域名解析出IP
IPHostEntry hostinfo = Dns.GetHostByName("baidu.com");
IPAddress[] aryIP = hostinfo.AddressList;
IPAddress address = aryIP[0];
在新版本编辑器中提示上述方法已过时
IPHostEntry ipHostInfo = Dns.GetHostEntry(domian);
IPAddress myip = ipHostInfo.AddressList[0];
return myip.ToString();