Get địa chỉ MacAddress fix bug

0 thích 0 không thích
1 lượt xem
đã hỏi 29 Tháng 9, 2022 trong Lập trình C# bởi nguyenthao (9,000 điểm)
public static List<string> GetMacAddress()
        {
            var list = new List<string>();           
            foreach (NetworkInterface networkInterface in NetworkInterface.GetAllNetworkInterfaces())
            {
                if (networkInterface.NetworkInterfaceType == NetworkInterfaceType.Ethernet)//&& networkInterface.OperationalStatus == OperationalStatus.Up)
                {
                    if (networkInterface.GetPhysicalAddress().ToString().Length > 11 && !networkInterface.GetPhysicalAddress().ToString().Contains("00000000000000"))
                    {
                        list.Add(networkInterface.GetPhysicalAddress().ToString());
                    }

                }

            }
            list.RemoveAll(item => string.IsNullOrEmpty(item));
            return list;
        }
Looking for an answer?  Share this question:     

Xin vui lòng đăng nhập hoặc đăng ký để trả lời câu hỏi này.

...