如何确保所选的网络适配器是以太网类型?
var networkInterface = NetworkInterface.GetAllNetworkInterfaces();
using System.Net.NetworkInformation;
...
...
private void detectNetworkAdapter()
{
foreach (NetworkInterface netInterface in NetworkInterface.GetAllNetworkInterfaces())
{
if (netInterface.OperationalStatus == OperationalStatus.Up)
{
Console.WriteLine(netInterface.NetworkInterfaceType.ToString());
return;
}
}
}
输出。以太网