C#获取本机的MAC地址

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management; namespace _17获取MAC地址
{
class Program
{
static void Main(string[] args)
{
ManagementObjectSearcher nisc = new ManagementObjectSearcher("select * from Win32_NetworkAdapterConfiguration");
foreach (ManagementObject nic in nisc.Get())
{
if (Convert.ToBoolean(nic["ipEnabled"]) == true)
{
Console.WriteLine("{0} - {1}", nic["ServiceName"], nic["MACAddress"]);
}
} Console.ReadKey();
}
}
}
上一篇:python3+requests:接口自动化测试(二)


下一篇:Intellij IDEA 解决 Maven 依赖下载慢的问题