标签:address get soc nbsp 地址 name stat private dns
private static string GetIP() { string ip = ""; System.Net.IPAddress[] addressList = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()); var tmp = addressList.Where(x => x.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork); foreach (var ips in tmp) { ip = ips.ToString(); } return ip; }
该方法需要引用:
using System.Linq;
调用:
string ip = GetIP();
标签:address get soc nbsp 地址 name stat private dns
原文地址:http://www.cnblogs.com/kwm672225801/p/7804616.html