NetworkInterface.NetworkInterfaceType Property

Definition

Gets the interface type.

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

Property Value

An NetworkInterfaceType value that specifies the network interface type.

Examples

The following example displays type information for all interfaces on the local computer.

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

Remarks

The interface types are described in detail in the System.Net.NetworkInformation.NetworkInterfaceType enumeration documentation.

In principle, this property can return any member of the NetworkInterfaceType enumeration. The specific value that it does return is dependent on the runtime conditions of the underlying network topology. This means that:

  • It is not possible to determine in advance which value the property returns for a particular network.

  • It is possible that in practice on a particular network, the full range of enumeration values is not available. For example, on a gigabit Ethernet network, it is possible that the property returns NetworkInterfaceType.Ethernet rather than NetworkInterfaceType.GigabitEthernet.

Applies to