Edit

Share via


NetworkInterface.GetAllNetworkInterfaces Method

Definition

Returns objects that describe the network interfaces on the local computer.

public:
 static cli::array <System::Net::NetworkInformation::NetworkInterface ^> ^ GetAllNetworkInterfaces();
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
public static System.Net.NetworkInformation.NetworkInterface[] GetAllNetworkInterfaces();
public static System.Net.NetworkInformation.NetworkInterface[] GetAllNetworkInterfaces();
[<System.Runtime.Versioning.UnsupportedOSPlatform("illumos")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("solaris")>]
static member GetAllNetworkInterfaces : unit -> System.Net.NetworkInformation.NetworkInterface[]
static member GetAllNetworkInterfaces : unit -> System.Net.NetworkInformation.NetworkInterface[]
Public Shared Function GetAllNetworkInterfaces () As NetworkInterface()

Returns

A NetworkInterface array that contains objects that describe the available network interfaces, or an empty array if no interfaces are detected.

Attributes

Exceptions

A Windows system function call failed.

Examples

The following code example displays Domain Name Service (DNS) configuration information for the local computer's network adapters.

public static void DisplayDnsConfiguration()
{
    NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in adapters)
    {
        IPInterfaceProperties properties = adapter.GetIPProperties();
        Console.WriteLine(adapter.Description);
        Console.WriteLine("  DNS suffix .............................. : {0}",
            properties.DnsSuffix);
        Console.WriteLine("  DNS enabled ............................. : {0}",
            properties.IsDnsEnabled);
        Console.WriteLine("  Dynamically configured DNS .............. : {0}",
            properties.IsDynamicDnsEnabled);
    }
    Console.WriteLine();
}
Public Shared Sub DisplayDnsConfiguration() 
    Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
    Dim adapter As NetworkInterface
    For Each adapter In  adapters
        Dim properties As IPInterfaceProperties = adapter.GetIPProperties()
        Console.WriteLine(adapter.Description)
        Console.WriteLine("  DNS suffix................................. :{0}", properties.DnsSuffix)
        Console.WriteLine("  DNS enabled ............................. : {0}", properties.IsDnsEnabled)
        Console.WriteLine("  Dynamically configured DNS .............. : {0}", properties.IsDynamicDnsEnabled)
    Next adapter

End Sub

Remarks

The network interfaces on a computer provide network connectivity. Network interfaces are also known as network adapters.

Applies to