1 public void GetNativeIp() 2 { 3 IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); 4 foreach(var ip in hostEntry.AddressList) 5 { 6 if (ip.AddressFamily == AddressFamily.InterNetwork) 7 { 8 IpAddress.Text = ip.ToString(); 9 } 10 } 11 }
标签:hostEntry,c#,ip,Dns,本机,AddressFamily From: https://www.cnblogs.com/zhaosanmao/p/17700083.html