如何得到我本地机器的所有IP?

作者: 孟宪会 出自: 【孟宪会之精彩世界】 发布日期: 2003-6-15 8:56:15

[C#]  
string s ="";  
System.Net.IPAddress[] addressList = Dns.GetHostByName(Dns.GetHostName()).AddressList; 
for (int i = 0; i < addressList.Length; i ++) 
{ 
    s += addressList[i].ToString() + "\n";  
} 
textBox1.Text = s;
[VB.NET]

Dim s As String = ""  
Dim addressList As System.Net.IPAddress() = Dns.GetHostByName(Dns.GetHostName()).AddressList 

Dim i As Integer  
For i = 0 To addressList.Length - 1  
    s += addressList(i).ToString() + ControlChars.Lf  
Next i 
textBox1.Text = s
Contributors: FHL