C# 获取 IPv4
作者:互联网
实现代码:
public static string GetLocalIPAddress() { var host = Dns.GetHostEntry(Dns.GetHostName()); foreach (var ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { return ip.ToString(); } } return ""; }
标签:return,C#,ip,获取,host,IPv4,Dns,var,AddressFamily 来源: https://www.cnblogs.com/Allofus/p/15305218.html