网络编程:获取本机主机名和IP地址
class Program { static void Main(string[] args) { string hostName = Dns.GetHostName(); Console.WriteLine("本电脑的名字为{0}",hostName); IPHostEntry myself = Dns.GetHostByName(hostName); foreach (IPAddress IPAddr in myself.AddressList) { Console.WriteLine("IP Address:{0}",IPAddr); } Console.ReadLine(); } }
清清软件园 http://sillysoft.taobao.com