NetworkInterface.Description 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取接口的描述。
public:
virtual property System::String ^ Description { System::String ^ get(); };
public:
abstract property System::String ^ Description { System::String ^ get(); };
public virtual string Description { get; }
public abstract string Description { get; }
member this.Description : string
Public Overridable ReadOnly Property Description As String
Public MustOverride ReadOnly Property Description As String
属性值
String,用于描述此接口。
示例
下面的代码示例显示本地计算机上所有接口的摘要。
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();
}
注解
说明是描述网络接口的可读文本。 说明中包含的信息取决于操作系统的功能。 在 Windows 上,它通常描述接口供应商、类型 (例如以太网) 、品牌和型号。 在其他平台上,它可能与接口的名称一样简短,例如 eth0
。