NetworkInterface.NetworkInterfaceType 属性

定义

获取接口类型。

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

属性值

NetworkInterfaceType 值,指定网络接口类型。

示例

以下示例显示本地计算机上所有接口的类型信息。

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

注解

枚举文档中详细介绍 System.Net.NetworkInformation.NetworkInterfaceType 了接口类型。

原则上,此属性可以返回枚举的任何成员 NetworkInterfaceType 。 它返回的特定值取决于基础网络拓扑的运行时条件。 这意味着:

适用于