NetworkInterface.Name Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan nama adaptor jaringan.
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
Nilai Properti
yang String berisi nama adaptor.
Contoh
Contoh kode berikut menampilkan ringkasan untuk semua antarmuka di komputer lokal.
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();
}
Berlaku untuk
Berkolaborasi dengan kami di GitHub
Sumber untuk konten ini dapat ditemukan di GitHub, yang juga dapat Anda gunakan untuk membuat dan meninjau masalah dan menarik permintaan. Untuk informasi selengkapnya, lihat panduan kontributor kami.