我想检索带有IP地址的MAC地址......
var nics = NetworkInterface.GetAllNetworkInterfaces()
.Where(ipProp => ipProp.GetIPProperties().UnicastAddresses
.Where(ip => ip.Address.ToString().Equals("192.168.1.111"))
);
我收到错误:
“无法将类型'System.Collections.Generic.IEnumerable'隐式转换为'bool'”
我该如何解决这个问题?
答案 0 :(得分:3)
NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces().Where(ipProp => ipProp.GetIPProperties().UnicastAddresses.FirstOrDefault(ip => ip.Address.ToString().Equals("YOUR_IP")) != null).FirstOrDefault();
if (networkInterface != null)
{
Console.WriteLine(networkInterface.GetPhysicalAddress());
}