C#获取本地的IP地址
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
/// 获取本地的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
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网