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.

適用於