Export (0) Print
Expand All

NetworkInterface.OperationalStatus Property

Note: This property is new in the .NET Framework version 2.0.

Gets the current operational state of the network connection.

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

public abstract OperationalStatus OperationalStatus { get; }
/** @property */
public abstract OperationalStatus get_OperationalStatus ()

public abstract function get OperationalStatus () : OperationalStatus

Property Value

One of the OperationalStatus values.

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

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

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

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2015 Microsoft