How to get default NIC Connection Name

后端 未结 6 1670
刺人心
刺人心 2021-01-01 02:27

IMPORTANT EDIT: Back again on this subject. As you said there should be no default NIC, I\'m trying to understand if there is a way to detect all the NICs t

6条回答
  •  无人及你
    2021-01-01 02:54

    You can get a list of them, but not the default (perhaps you can assume it is the first entry).

    static void Main(string[] args)
    {
      foreach (var nc in NetworkInterface.GetAllNetworkInterfaces())
      {
        Console.WriteLine(nc.Name);
      }
    
      Console.ReadLine();
    }
    

提交回复
热议问题