PhysicalAddress 클래스

정의

네트워크 인터페이스(어댑터)에 MAC(Media Access Control) 주소를 제공합니다.

public ref class PhysicalAddress
public class PhysicalAddress
type PhysicalAddress = class
Public Class PhysicalAddress
상속
PhysicalAddress

예제

다음 코드 예제에서는 로컬 컴퓨터에 있는 모든 인터페이스의 실제 주소를 표시 합니다.

void ShowNetworkInterfaces()
{
   IPGlobalProperties^ computerProperties = IPGlobalProperties::GetIPGlobalProperties();
   array<NetworkInterface^>^nics = NetworkInterface::GetAllNetworkInterfaces();
   Console::WriteLine( L"Interface information for {0}.{1}     ", computerProperties->HostName, computerProperties->DomainName );
   if ( nics == nullptr || nics->Length < 1 )
   {
      Console::WriteLine( L"  No network interfaces found." );
      return;
   }

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

      }
      Console::WriteLine();
   }
}
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();
    }
}

설명

MAC 주소 또는 물리적 주소는 네트워크에서 컴퓨터 또는 프린터와 같은 각 노드를 고유하게 식별하는 하드웨어 주소입니다.

이 클래스의 인스턴스는 메서드에서 NetworkInterface.GetPhysicalAddress 반환됩니다.

생성자

PhysicalAddress(Byte[])

PhysicalAddress 클래스의 새 인스턴스를 초기화합니다.

필드

None

길이가 0인 주소를 사용하는 새 PhysicalAddress 인스턴스를 반환합니다. 이 필드는 읽기 전용입니다.

메서드

Equals(Object)

두 개의 PhysicalAddress 인스턴스를 비교합니다.

GetAddressBytes()

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

GetHashCode()

실제 주소의 해시 값을 반환합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
Parse(ReadOnlySpan<Char>)

지정된 범위를 구문 분석하고 해당 내용을 이 메서드에서 반환된 PhysicalAddress의 주소 바이트로 저장합니다.

Parse(String)

지정된 String을 구문 분석하고 해당 내용을 이 메서드에서 반환된 PhysicalAddress의 주소 바이트로 저장합니다.

ToString()

이 인스턴스의 주소에 대한 String 표현을 반환합니다.

TryParse(ReadOnlySpan<Char>, PhysicalAddress)

하드웨어 주소의 범위 표현을 PhysicalAddress 인스턴스로 변환하려고 시도합니다. 반환 값은 변환의 성공 여부를 나타냅니다.

TryParse(String, PhysicalAddress)

하드웨어 주소의 문자열 표현을 PhysicalAddress 인스턴스로 변환하려고 시도합니다. 반환 값은 변환의 성공 여부를 나타냅니다.

적용 대상