Aracılığıyla paylaş


PhysicalAddress(Byte[]) Oluşturucu

Tanım

PhysicalAddress sınıfının yeni bir örneğini başlatır.

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())

Parametreler

address
Byte[]

Byte Adresi içeren bir dizi.

Örnekler

Aşağıdaki kod örneği yeni PhysicalAddress bir nesne oluşturur.

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

Açıklamalar

Yaygın senaryolarda uygulamaların bu oluşturucuyu çağırması gerekmez; bu sınıfın örnekleri yöntemi tarafından GetPhysicalAddress döndürülür.

yöntemini kullanarak Parse yeni bir örneğini de oluşturabileceğinizi PhysicalAddressunutmayın.

Şunlara uygulanır