次の方法で共有


PhysicalAddress(Byte[]) コンストラクター

定義

PhysicalAddress クラスの新しいインスタンスを初期化します。

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

パラメーター

address
Byte[]

アドレスを格納している Byte 配列。

次のコード例では、新 PhysicalAddress しい オブジェクトを作成します。

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

注釈

一般的なシナリオでは、アプリケーションはこのコンストラクターを呼び出す必要はありません。このクラスのインスタンスは、 メソッドによって GetPhysicalAddress 返されます。

メソッドを使用して の Parse 新しいインスタンス PhysicalAddressを作成することもできます。

適用対象