C#获取本机IP地址

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

C#获取本机IP地址

using System.Net;
using System.Net.Sockets;
string name = Dns.GetHostName();
var ipv4 = Dns.GetHostEntry(name).AddressList.Where(i => i.AddressFamily == AddressFamily.InterNetwork).FirstOrDefault();
textBox1.Text =string.Format("{0}:{1}",name,ipv4.ToString());