PhysicalAddress.GetAddressBytes 메서드

정의

현재 인스턴스의 주소를 반환합니다.

public:
 cli::array <System::Byte> ^ GetAddressBytes();
public byte[] GetAddressBytes();
member this.GetAddressBytes : unit -> byte[]
Public Function GetAddressBytes () As Byte()

반품

Byte[]

Byte 주소를 포함하는 배열입니다.

예제

다음 코드 예제에서는 이 메서드를 호출하여 주소 PhysicalAddress 의 주소를 검색하고 표시할 주소의 형식을 지정합니다.

public static void ShowNetworkInterfaces()
{
    IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
    NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
    Console.WriteLine("Interface information for {0}.{1}     ",
            computerProperties.HostName, computerProperties.DomainName);
    if (nics == null || nics.Length < 1)
    {
        Console.WriteLine("  No network interfaces found.");
        return;
    }

    Console.WriteLine("  Number of interfaces .................... : {0}", nics.Length);
    foreach (NetworkInterface adapter in nics)
    {
        IPInterfaceProperties properties = adapter.GetIPProperties(); //  .GetIPInterfaceProperties();
        Console.WriteLine();
        Console.WriteLine(adapter.Description);
        Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length, '='));
        Console.WriteLine("  Interface type .......................... : {0}", adapter.NetworkInterfaceType);
        Console.Write("  Physical address ........................ : ");
        PhysicalAddress address = adapter.GetPhysicalAddress();
        byte[] bytes = address.GetAddressBytes();
        for (int i = 0; i < bytes.Length; i++)
        {
            // Display the physical address in hexadecimal.
            Console.Write("{0}", bytes[i].ToString("X2"));
            // Insert a hyphen after each byte, unless we're at the end of the address.
            if (i != bytes.Length - 1)
            {
                Console.Write("-");
            }
        }
        Console.WriteLine();
    }
}

적용 대상