c# 获取本机ip地址的方法
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 }

浙公网安备 33010602011771号