NetworkInterface.Name Propriété

Définition

Obtient le nom de la carte réseau.

public:
 abstract property System::String ^ Name { System::String ^ get(); };
public:
 virtual property System::String ^ Name { System::String ^ get(); };
public abstract string Name { get; }
public virtual string Name { get; }
member this.Name : string
Public MustOverride ReadOnly Property Name As String
Public Overridable ReadOnly Property Name As String

Valeur de propriété

Qui String contient le nom de l’adaptateur.

Exemples

L’exemple de code suivant affiche un résumé pour toutes les interfaces sur l’ordinateur local.

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

S’applique à