NetworkInterface.GetAllNetworkInterfaces Metod

Definition

Returnerar objekt som beskriver nätverksgränssnitten på den lokala datorn.

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();
[System.Runtime.Versioning.UnsupportedOSPlatform("illumos")]
[System.Runtime.Versioning.UnsupportedOSPlatform("solaris")]
[System.Runtime.Versioning.UnsupportedOSPlatform("haiku")]
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[]
[<System.Runtime.Versioning.UnsupportedOSPlatform("illumos")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("solaris")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("haiku")>]
static member GetAllNetworkInterfaces : unit -> System.Net.NetworkInformation.NetworkInterface[]
static member GetAllNetworkInterfaces : unit -> System.Net.NetworkInformation.NetworkInterface[]
Public Shared Function GetAllNetworkInterfaces () As NetworkInterface()

Returer

En NetworkInterface matris som innehåller objekt som beskriver tillgängliga nätverksgränssnitt eller en tom matris om inga gränssnitt identifieras.

Attribut

Undantag

Ett Windows systemfunktionsanrop misslyckades.

Exempel

I följande kodexempel visas dns-konfigurationsinformation (Domain Name Service) för den lokala datorns nätverkskort.

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

Kommentarer

Nätverksgränssnitten på en dator ger nätverksanslutning. Nätverksgränssnitt kallas även nätverkskort.

Gäller för