IPInterfaceProperties::GatewayAddresses Property
.NET Framework (current version)
Gets the IPv4 network gateway addresses for this interface.
Assembly: System (in System.dll)
public: property GatewayIPAddressInformationCollection^ GatewayAddresses { virtual GatewayIPAddressInformationCollection^ get() abstract; }
Property Value
Type: System.Net.NetworkInformation::GatewayIPAddressInformationCollection^An GatewayIPAddressInformationCollection that contains the address information for network gateways, or an empty array if no gateways are found.
Gateways that implement the Internet Protocol Version 4 (IPv4) to forward packets between networks are returned by this property.
The following code example displays the gateway addresses for the network interfaces on the local computer.
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(); } } }
.NET Framework
Available since 2.0
Available since 2.0
Show: