获取IP地址

 IPAddress[] ip=   Dns.GetHostAddresses(Dns.GetHostName());
         foreach (var item in ip)
         {
             if (item.AddressFamily.Equals(AddressFamily.InterNetwork))
             {
                 Console.WriteLine(item.ToString());
             }   
         }
         Console.ReadKey();
View Code

 

posted on 2016-11-30 15:25  路上有你F  阅读(83)  评论(0编辑  收藏  举报