C# 获得本地IP地址

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

    string hostName = System.Net.Dns.GetHostName();  
               //hostName获取主机名称  
               System.Net.IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(hostName);//Dns.GetHostByName(hostName);            
               //ip地址列表  
               System.Net.IPAddress[] addr = ipEntry.AddressList;  
               string add = addr[0].ToString();