CSharp实现url2ip

  • 代码实现:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class client
{
public string GeturlIP(string URL){
string IP = string.Empty;
try{
IPHostEntry ipinfo = Dns.GetHostEntry(URL);
foreach(IPAddress IPADDRESS in ipinfo.AddressList)
{
IP = IPADDRESS.ToString();
}
}
catch {}
return IP;
}
}