Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
OperationalStatus Property

NetworkInterface.OperationalStatus Property

Gets the current operational state of the network connection.

Namespace:  System.Net.NetworkInformation
Assembly:  System (in System.dll)

public abstract OperationalStatus OperationalStatus { get; }

The operational status values are described in detail in the OperationalStatus enumeration documentation.

The following code example displays a summary for all interfaces on the local computer.

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();
}
void ShowInterfaceSummary()
{

    NetworkInterface* interfaces[] = NetworkInterface::GetAllNetworkInterfaces();
    System::Collections::IEnumerator* myEnum5 = interfaces->GetEnumerator();
    while (myEnum5->MoveNext())
    {
        NetworkInterface* adapter = __try_cast<NetworkInterface*>(myEnum5->Current);                
        Console::WriteLine (S"Name: {0}", adapter->Name);
        Console::WriteLine(adapter->Description);
        Console::WriteLine(String::Empty->PadLeft(adapter->Description->Length,'='));
        Console::WriteLine(S"  Interface type .......................... : {0}", __box(adapter->Type));
        Console::WriteLine(S"  Operational status ...................... : {0}", __box(adapter->OperationalStatus));
        String* versions =S"";

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2015 Microsoft