using System.Net;


Dns.GetHostName();//获取本地计算机主机名

IPAddress[] IP = Dns.GetHostAddresses(Dns.GetHostName());// 根据主机名或 IP 地址返回指定主机的 Internet 协议 (IP) 地址。
List<string> list = new List<string>();
foreach (var item in IP)
{
if (item.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
list.Add(item.ToString());
//item.ToString();
}
Console.WriteLine(Dns.GetHostName() + "\r\n" + string.Join("\r\n", list));

相关文章:

  • 2021-05-26
  • 2022-01-29
  • 2022-12-23
  • 2021-11-14
  • 2021-09-19
  • 2022-12-23
  • 2022-01-03
猜你喜欢
  • 2021-06-19
  • 2021-09-17
  • 2022-12-23
  • 2021-06-13
  • 2021-09-12
  • 2022-12-23
  • 2021-11-24
相关资源
相似解决方案