OperationalStatus 枚举

定义

指定网络接口的操作状态。Specifies the operational state of a network interface.

public enum class OperationalStatus
public enum OperationalStatus
type OperationalStatus = 
Public Enum OperationalStatus
继承
OperationalStatus

字段

Dormant 5

网络接口不处于传输数据包的状态;它正等待外部事件。The network interface is not in a condition to transmit data packets; it is waiting for an external event.

Down 2

网络接口无法传输数据包。The network interface is unable to transmit data packets.

LowerLayerDown 7

网络接口无法传输数据包,因为它运行在一个或多个其他接口之上,而这些“低层”接口中至少有一个已关闭。The network interface is unable to transmit data packets because it runs on top of one or more other interfaces, and at least one of these "lower layer" interfaces is down.

NotPresent 6

由于缺少组件(通常为硬件组件),网络接口无法传输数据包。The network interface is unable to transmit data packets because of a missing component, typically a hardware component.

Testing 3

网络接口正在运行测试。The network interface is running tests.

Unknown 4

网络接口的状态未知。The network interface status is not known.

Up 1

网络接口已运行,可以传输数据包。The network interface is up; it can transmit data packets.

示例

下面的代码示例为本地计算机上的所有接口显示一个摘要。The following code example displays a summary for all interfaces on the local computer.

void ShowInterfaceSummary()
{
   array<NetworkInterface^>^interfaces = NetworkInterface::GetAllNetworkInterfaces();
   System::Collections::IEnumerator^ myEnum5 = interfaces->GetEnumerator();
   while ( myEnum5->MoveNext() )
   {
      NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum5->Current);
      Console::WriteLine( "Name: {0}", adapter->Name );
      Console::WriteLine( adapter->Description );
      Console::WriteLine( String::Empty->PadLeft( adapter->Description->Length, '=' ) );
      Console::WriteLine( "  Interface type .......................... : {0}",
         adapter->NetworkInterfaceType );
      Console::WriteLine( "  Operational status ...................... : {0}", adapter->OperationalStatus );
      String^ versions = "";

      // Create a display string for the supported IP versions.
      if ( adapter->Supports( NetworkInterfaceComponent::IPv4 ) )
      {
         versions = "IPv4";
      }

      if ( adapter->Supports( NetworkInterfaceComponent::IPv6 ) )
      {
         if ( versions->Length > 0 )
         {
            versions = String::Concat( versions, " " );
         }

         versions = String::Concat( versions, "IPv6" );
      }

      Console::WriteLine( "  IP version .............................. : {0}", versions );
      Console::WriteLine();
   }

   Console::WriteLine();
}
public static void ShowInterfaceSummary()
{
    
    NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in interfaces)
    {                
        Console.WriteLine ("Name: {0}", adapter.Name);
        Console.WriteLine(adapter.Description);
        Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length,'='));
        Console.WriteLine("  Interface type .......................... : {0}", adapter.NetworkInterfaceType);
        Console.WriteLine("  Operational status ...................... : {0}", 
            adapter.OperationalStatus);
        string versions ="";

        // Create a display string for the supported IP versions.
        if (adapter.Supports(NetworkInterfaceComponent.IPv4))
        {
             versions = "IPv4";
         }
        if (adapter.Supports(NetworkInterfaceComponent.IPv6))
        {
            if (versions.Length > 0)
            {
                versions += " ";
             }
            versions += "IPv6";
        }
        Console.WriteLine("  IP version .............................. : {0}", versions);
        Console.WriteLine();
    }
    Console.WriteLine();
}

注解

此枚举定义OperationalStatus属性的有效值。This enumeration defines valid values for the OperationalStatus property.

适用于