代码:
var macAddr =
(from nic in NetworkInterface.GetAllNetworkInterfaces()
where nic.OperationalStatus == OperationalStatus.Up
select nic.GetPhysicalAddress().ToString()).FirstOrDefault();
输出:
0800275283A8
如何隐蔽:
08:00:27:52:83:A8
答案 0 :(得分:1)
试试这个:
var macAddr =
(from nic in NetworkInterface.GetAllNetworkInterfaces()
where nic.OperationalStatus == OperationalStatus.Up
select nic.GetPhysicalAddress().GetAddressBytes()).FirstOrDefault();
string formattedMacAddr = string.Join (":", (from z in macAddr select z.ToString ("X2")).ToArray());
Console.WriteLine(formattedMacAddr);
//outputs this format: 08:00:27:52:83:A8