C#獲取IP和主機名

hikarusun發表於2014-04-16

System.Net.IPAddress addr;

//獲取IP

addr = new System.Net.IPAddress ( Dns.GetHostByName ( Dns.GetHostName ( ) ) .AddressList [0].Address ) ; return addr.ToString ( ) ;

//獲取PCname

string pcname=Dns.GetHostName();

 

相關文章