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

后端 未结 9 847
梦谈多话
梦谈多话 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:24

    For a hybrid dictionary, I use this:

    List keys = new List(dictionary.Count);
    keys.AddRange(dictionary.Keys.Cast());
    

提交回复
热议问题