How do I get the list of keys in a Dictionary?

后端 未结 9 848
梦谈多话
梦谈多话 2020-12-02 11:38

I only want the Keys and not the Values of a Dictionary.

I haven\'t been able to get any code to do this yet. Using another array proved to be too much work as I use

9条回答
  •  星月不相逢
    2020-12-02 12:23

    To get list of all keys

    using System.Linq;
    List myKeys = myDict.Keys.ToList();
    

    System.Linq is supported in .Net framework 3.5 or above. See the below links if you face any issue in using System.Linq

    Visual Studio Does not recognize System.Linq

    System.Linq Namespace

提交回复
热议问题