Building a dictionary of counts of items in a list

后端 未结 5 1391
广开言路
广开言路 2021-01-02 06:08

I have a List containing a bunch of strings that can occur more than once. I would like to take this list and build a dictionary of the list items as the key and the count

5条回答
  •  遥遥无期
    2021-01-02 06:57

    Well, there isn't really any better way to do it.

    Perhaps you could write a LINQ query that would group the strings and then count how many strings there are in each group, but that would not be nearly as efficient as what you already have.

提交回复
热议问题