PhysicalAddress(Byte[]) Konstruktor

Definition

Initialisiert eine neue Instanz der 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())

Parameter

address
Byte[]

Ein Byte Array, das die Adresse enthält.

Beispiele

Im folgenden Codebeispiel wird ein neues PhysicalAddress Objekt erstellt.

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;
}

Hinweise

In gängigen Szenarien müssen Anwendungen diesen Konstruktor nicht aufrufen. Instanzen dieser Klasse werden von der GetPhysicalAddress Methode zurückgegeben.

Beachten Sie, dass Sie die Parse Methode auch verwenden können, um eine neue Instanz von PhysicalAddress.

Gilt für: