WebApplication4.Models.Utilitarios2.GetMacAddress C# (CSharp) Méthode

GetMacAddress() public static méthode

Gets the MAC address of the current PC.
public static GetMacAddress ( ) : System.Net.NetworkInformation.PhysicalAddress
Résultat System.Net.NetworkInformation.PhysicalAddress
        public static PhysicalAddress GetMacAddress()
        {
            foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
            {
                // Only consider Ethernet network interfaces
                if (nic.NetworkInterfaceType == NetworkInterfaceType.Ethernet &&
                    nic.OperationalStatus == OperationalStatus.Up)
                {
                    return nic.GetPhysicalAddress();
                }
            }
            return null;
        }