IPInterfaceProperties.GatewayAddresses Propriété
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient les adresses des passerelles réseau IPv4 pour cette interface.
public:
abstract property System::Net::NetworkInformation::GatewayIPAddressInformationCollection ^ GatewayAddresses { System::Net::NetworkInformation::GatewayIPAddressInformationCollection ^ get(); };
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
public abstract System.Net.NetworkInformation.GatewayIPAddressInformationCollection GatewayAddresses { get; }
public abstract System.Net.NetworkInformation.GatewayIPAddressInformationCollection GatewayAddresses { get; }
[<System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
member this.GatewayAddresses : System.Net.NetworkInformation.GatewayIPAddressInformationCollection
member this.GatewayAddresses : System.Net.NetworkInformation.GatewayIPAddressInformationCollection
Public MustOverride ReadOnly Property GatewayAddresses As GatewayIPAddressInformationCollection
GatewayIPAddressInformationCollection qui contient les informations d'adresses pour les passerelles réseau ou un tableau vide si aucune passerelle n'est trouvée.
- Attributs
L’exemple de code suivant affiche les adresses de passerelle pour les interfaces réseau sur l’ordinateur local.
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
Les passerelles qui implémentent le protocole Internet Version 4 (IPv4) pour transférer des paquets entre les réseaux sont retournées par cette propriété.
Produit | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
Commentaires sur .NET
.NET est un projet open source. Sélectionnez un lien pour fournir des commentaires: