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를 만들 수도 있습니다.

적용 대상