NetworkInterface.NetworkInterfaceType Propriété

Définition

Obtient le type d'interface.

public:
 virtual property System::Net::NetworkInformation::NetworkInterfaceType NetworkInterfaceType { System::Net::NetworkInformation::NetworkInterfaceType get(); };
public:
 abstract property System::Net::NetworkInformation::NetworkInterfaceType NetworkInterfaceType { System::Net::NetworkInformation::NetworkInterfaceType get(); };
public virtual System.Net.NetworkInformation.NetworkInterfaceType NetworkInterfaceType { get; }
public abstract System.Net.NetworkInformation.NetworkInterfaceType NetworkInterfaceType { get; }
member this.NetworkInterfaceType : System.Net.NetworkInformation.NetworkInterfaceType
Public Overridable ReadOnly Property NetworkInterfaceType As NetworkInterfaceType
Public MustOverride ReadOnly Property NetworkInterfaceType As NetworkInterfaceType

Valeur de propriété

Valeur NetworkInterfaceType qui spécifie le type d'interface réseau.

Exemples

L’exemple suivant affiche les informations de type pour toutes les interfaces sur l’ordinateur local.

void DisplayTypeAndAddress()
{
   IPGlobalProperties ^ computerProperties = IPGlobalProperties::GetIPGlobalProperties();
   array<NetworkInterface^>^nics = NetworkInterface::GetAllNetworkInterfaces();
   Console::WriteLine( "Interface information for {0}.{1}     ", computerProperties->HostName, computerProperties->DomainName );
   System::Collections::IEnumerator^ myEnum27 = nics->GetEnumerator();
   while ( myEnum27->MoveNext() )
   {
      NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum27->Current);
      IPInterfaceProperties ^ properties = adapter->GetIPProperties();
      Console::WriteLine( adapter->Description );
      Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) );
      Console::WriteLine( "  Interface type .......................... : {0}", 
         adapter->NetworkInterfaceType );
      Console::WriteLine( "  Physical Address ........................ : {0}", 
         adapter->GetPhysicalAddress() );
      Console::WriteLine( "  Is receive only.......................... : {0}", 
         adapter->IsReceiveOnly );
      Console::WriteLine( "  Multicast................................ : {0}", 
         adapter->SupportsMulticast );
   }
}
public static void DisplayTypeAndAddress()
{
    IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties();
    NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
    Console.WriteLine("Interface information for {0}.{1}     ",
            computerProperties.HostName, computerProperties.DomainName);
    foreach (NetworkInterface adapter in nics)
    {
        IPInterfaceProperties properties = adapter.GetIPProperties();
        Console.WriteLine(adapter.Description);
        Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length,'='));
        Console.WriteLine("  Interface type .......................... : {0}", adapter.NetworkInterfaceType);
        Console.WriteLine("  Physical Address ........................ : {0}",
                   adapter.GetPhysicalAddress().ToString());
        Console.WriteLine("  Is receive only.......................... : {0}", adapter.IsReceiveOnly);
        Console.WriteLine("  Multicast................................ : {0}", adapter.SupportsMulticast);
        Console.WriteLine();
      }
   }
Public Shared Sub DisplayTypeAndAddress() 
    Dim computerProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
    Dim nics As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
    Console.WriteLine("Interface information for {0}.{1}     ", computerProperties.HostName, computerProperties.DomainName)
    Dim adapter As NetworkInterface
    For Each adapter In  nics
        Dim properties As IPInterfaceProperties = adapter.GetIPProperties()
        Console.WriteLine(adapter.Description)
        Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length, "="c))
        Console.WriteLine("  Interface type .......................... : {0}", adapter.NetworkInterfaceType)
        Console.WriteLine("  Physical Address ........................ : {0}", adapter.GetPhysicalAddress().ToString())
        Console.WriteLine("  Is receive only.......................... : {0}", adapter.IsReceiveOnly)
        Console.WriteLine("  Multicast................................ : {0}", adapter.SupportsMulticast)
    Next adapter

End Sub

Remarques

Les types d’interface sont décrits en détail dans la documentation de l’énumération System.Net.NetworkInformation.NetworkInterfaceType .

En principe, cette propriété peut renvoyer n’importe quel membre de l’énumération NetworkInterfaceType . La valeur spécifique retournée dépend des conditions d’exécution de la topologie réseau sous-jacente. Cela signifie que :

  • Il n’est pas possible de déterminer à l’avance la valeur renvoyée par la propriété pour un réseau particulier.

  • Il est possible que, dans la pratique, sur un réseau particulier, la plage complète de valeurs d’énumération ne soit pas disponible. Par exemple, sur un réseau Ethernet gigabit, il est possible que la propriété retourne NetworkInterfaceType.Ethernet plutôt que NetworkInterfaceType.GigabitEthernet.

S’applique à