C#获得本机ip地址

string s="";
System.Net.IPAddress[] addressList = Dns.GetHostByName(Dns.GetHostName()).AddressList; 
for (int i = 0; i < addressList.Length; i ++)
{
s += addressList[i].ToString();
}

编程技巧