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

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

    I can't believe all these convoluted answers. Assuming the key is of type: string (or use 'var' if you're a lazy developer): -

    List listOfKeys = theCollection.Keys.ToList();
    

提交回复
热议问题