@byxiaoxie5 年前

03/13
00:03
Home

C# 域名转IP地址

引用:using System.Net;
/// <summary>
/// 域名转IP
/// </summary>
/// <param name="domain">域名</param>
public static string getIP(string domain)
{
    domain = domain.Replace("http://", "").Replace("https://", "");
    IPHostEntry host = Dns.GetHostEntry(domain);
    IPEndPoint ip = new IPEndPoint(host.AddressList[0], 0);
    return ip.Address.ToString();
}

C# 域名转IP地址

加载中……