PhysicalAddress(Byte[]) Constructor

Definitie

Initialiseert een nieuw exemplaar van de PhysicalAddress klasse.

public:
 PhysicalAddress(cli::array <System::Byte> ^ address);
public PhysicalAddress(byte[] address);
new System.Net.NetworkInformation.PhysicalAddress : byte[] -> System.Net.NetworkInformation.PhysicalAddress
Public Sub New (address As Byte())

Parameters

address
Byte[]

Een Byte matrix met het adres.

Voorbeelden

In het volgende codevoorbeeld wordt een nieuw PhysicalAddress object gemaakt.

public static PhysicalAddress[]? StoreNetworkInterfaceAddresses()
{
    IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
    NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
    if (nics == null || nics.Length < 1)
    {
        Console.WriteLine("  No network interfaces found.");
        return null;
    }

    PhysicalAddress[] addresses = new PhysicalAddress[nics.Length];
    int i = 0;
    foreach (NetworkInterface adapter in nics)
    {
        IPInterfaceProperties properties = adapter.GetIPProperties();
        PhysicalAddress address = adapter.GetPhysicalAddress();
        byte[] bytes = address.GetAddressBytes();
        PhysicalAddress newAddress = new PhysicalAddress(bytes);
        addresses[i++] = newAddress;
    }
    return addresses;
}

Opmerkingen

In veelvoorkomende scenario's hoeven toepassingen deze constructor niet aan te roepen; exemplaren van deze klasse worden geretourneerd door de GetPhysicalAddress methode.

U kunt ook de Parse methode gebruiken om een nieuw exemplaar van PhysicalAddress.

Van toepassing op