NetworkInterface.Name Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the name of the network adapter.
public:
virtual property System::String ^ Name { System::String ^ get(); };
public:
abstract property System::String ^ Name { System::String ^ get(); };
public virtual string Name { get; }
public abstract string Name { get; }
member this.Name : string
Public Overridable ReadOnly Property Name As String
Public MustOverride ReadOnly Property Name As String
Property Value
A String that contains the adapter name.
Examples
The following code example displays a summary for all interfaces on the local computer.
void ShowInterfaceSummary()
{
array<NetworkInterface^>^interfaces = NetworkInterface::GetAllNetworkInterfaces();
System::Collections::IEnumerator^ myEnum5 = interfaces->GetEnumerator();
while ( myEnum5->MoveNext() )
{
NetworkInterface ^ adapter = safe_cast<NetworkInterface ^>(myEnum5->Current);
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 = String::Concat( versions, " " );
}
versions = String::Concat( versions, "IPv6" );
}
Console::WriteLine( " IP version .............................. : {0}", versions );
Console::WriteLine();
}
Console::WriteLine();
}
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();
}
Applies to
GitHub पर हमारे साथ सहयोग करें
इस सामग्री का स्रोत GitHub पर पाया जा सकता है, जहाँ आप समस्याएँ बना और समीक्षा भी कर सकते हैं और अनुरोध खींच सकते हैं. अधिक जानकारी के लिए, हमारे योगदानकर्ता गाइड देखें.