C# Winform 域名得到(查询)(服务器所在) IP  cs

public string GetIPByDomain(string url)
{
    if (url.Trim() == string.Empty)
        return "";
   try
    {
        System.Net.IPHostEntry host = System.Net.Dns.GetHostEntry(url);
        return host.AddressList.GetValue(0).ToString();
   }
    catch (Exception e)
    {
       throw e;
    }
}
 

							
		
原文地址:https://www.cnblogs.com/binlunia/p/11267788.html