다음을 통해 공유


IPInterfaceProperties.GatewayAddresses 속성

정의

이 인터페이스에 대한 IPv4 네트워크 게이트웨이 주소를 가져옵니다.

public:
 abstract property System::Net::NetworkInformation::GatewayIPAddressInformationCollection ^ GatewayAddresses { System::Net::NetworkInformation::GatewayIPAddressInformationCollection ^ get(); };
public abstract System.Net.NetworkInformation.GatewayIPAddressInformationCollection GatewayAddresses { get; }
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.GatewayIPAddressInformationCollection GatewayAddresses { get; }
member this.GatewayAddresses : System.Net.NetworkInformation.GatewayIPAddressInformationCollection
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
member this.GatewayAddresses : System.Net.NetworkInformation.GatewayIPAddressInformationCollection
Public MustOverride ReadOnly Property GatewayAddresses As GatewayIPAddressInformationCollection

속성 값

네트워크 게이트웨이에 대한 주소 정보가 들어 있는 GatewayIPAddressInformationCollection이거나, 게이트웨이를 찾을 수 없는 경우 빈 배열입니다.

특성

예제

다음 코드 예제에서는 로컬 컴퓨터의 네트워크 인터페이스에 대 한 게이트웨이 주소를 표시 합니다.

void DisplayGatewayAddresses()
{
   Console::WriteLine( "Gateways" );
   array<NetworkInterface^>^adapters = NetworkInterface::GetAllNetworkInterfaces();
   System::Collections::IEnumerator^ myEnum21 = adapters->GetEnumerator();
   while ( myEnum21->MoveNext() )
   {
      NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum21->Current);
      IPInterfaceProperties ^ adapterProperties = adapter->GetIPProperties();
      GatewayIPAddressInformationCollection ^ addresses = adapterProperties->GatewayAddresses;
      if ( addresses->Count > 0 )
      {
         Console::WriteLine( adapter->Description );
         System::Collections::IEnumerator^ myEnum22 = addresses->GetEnumerator();
         while ( myEnum22->MoveNext() )
         {
            GatewayIPAddressInformation^ address = safe_cast<GatewayIPAddressInformation^>(myEnum22->Current);
            Console::WriteLine( "  Gateway Address ......................... : {0}", 
               address->Address->ToString() );
         }
         Console::WriteLine();
      }
   }
}
public static void DisplayGatewayAddresses()
{
    Console.WriteLine("Gateways");
    NetworkInterface[] adapters  = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in adapters)
    {
        IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
        GatewayIPAddressInformationCollection addresses = adapterProperties.GatewayAddresses;
        if (addresses.Count >0)
        {
            Console.WriteLine(adapter.Description);
            foreach (GatewayIPAddressInformation address in addresses)
            {
                Console.WriteLine("  Gateway Address ......................... : {0}",
                    address.Address.ToString());
            }
            Console.WriteLine();
        }
    }
}
Public Shared Sub DisplayGatewayAddresses() 
    Console.WriteLine("Gateways")
    Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
    Dim adapter As NetworkInterface
    For Each adapter In  adapters
        Dim adapterProperties As IPInterfaceProperties = adapter.GetIPProperties()
        Dim addresses As GatewayIPAddressInformationCollection = adapterProperties.GatewayAddresses
        If addresses.Count > 0 Then
            Console.WriteLine(adapter.Description)
            Dim address As GatewayIPAddressInformation
            For Each address In  addresses
                Console.WriteLine("  Gateway Address ......................... : {0}", address.ToString())
            Next address
            Console.WriteLine()
        End If
    Next adapter

End Sub

설명

네트워크 간에 패킷을 전달하기 위해 IPv4(인터넷 프로토콜 버전 4)를 구현하는 게이트웨이는 이 속성에서 반환됩니다.

적용 대상