C#通过域名获得IP地址的代码

using System.Net;
string web = txtWeb.Text;
IPHostEntry host = Dns.GetHostByName(web);
IPAddress ip = host.AddressList[0];
txtIp.Text = ip.ToString();

编程技巧