C#获取本地的IP地址
作者:C/S框架网|www.cscode.ne  发布日期:2020-04-13 16:46:53
  C#获取本地的IP地址


C# Code:

/// <summary>
/// 获取本地的IP地址
/// </summary>
/// <returns></returns>
public static string GetLocalIP()
{
  
//InterNetwork 获取内网IP
  
string AddressIP = string.Empty;
  
foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
  {
    
if (_IPAddress.AddressFamily.ToString() == "InterNetwork")
    {
      AddressIP
= _IPAddress.ToString();
    }
  }
  
  
return AddressIP;
}

//来源:C/S框架网 | www.csframework.com | QQ:23404761



上一篇 下一篇