c# 读取网卡Mac

        ///<summary>
        /// 通过NetworkInterface读取网卡Mac
        ///</summary>
        ///<returns></returns>
        public static string GetMacByNetworkInterface()
        {
            List<string> macs = new List<string>();
            NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
            return interfaces.Where(p => p.OperationalStatus == OperationalStatus.Up).FirstOrDefault().GetPhysicalAddress().ToString();

        }

 

posted @ 2018-06-20 10:55  liuyong111  阅读(498)  评论(0编辑  收藏  举报