如何知道网络适配器是否为以太网类型[关闭] ...

问题描述 投票:-1回答:1

如何确保所选的网络适配器是以太网类型?

var networkInterface = NetworkInterface.GetAllNetworkInterfaces();
c# ip-address
1个回答
-1
投票
using System.Net.NetworkInformation;
...
...
private void detectNetworkAdapter()
        {
            foreach (NetworkInterface netInterface in NetworkInterface.GetAllNetworkInterfaces())
            {
                if (netInterface.OperationalStatus == OperationalStatus.Up)
                {
                    Console.WriteLine(netInterface.NetworkInterfaceType.ToString());
                    return;                 
                }
            }
        }

输出。以太网

© www.soinside.com 2019 - 2024. All rights reserved.