通过代码获取本机 IP 代码
//获取电脑名称
var name = Dns.GetHostName();
Console.WriteLine("HostName:" + name);
//获取网卡地址列表
var addressList = Dns.GetHostEntry(name).AddressList;
//筛选IPv4地址
var ipv4 = addressList.Where(i => i.AddressFamily == AddressFamily.InterNetwork).FirstOrDefault();
Console.WriteLine("ipv4 IP:" + ipv4);
版权属于:zgcwkj
本文链接:https://blog.zgcwkj.cn/archives/209.html
转载声明:请注明本文章的标题及内容的出处和声明,谢谢
评论已关闭