I have a list that looks something like this . . .
List<string> l =
new List<string>() {
"A", "A",
"A", "A", "B",
"C", "C",
"C", "C", "C",
"D", "D" };
. . . and I want to end up with a dictionary that counts the number of occurrences of each value in the list.
Something like this.
Dictionary<string,
int> d = new
Dictionary<string,
int>() { { "A", 4 }, {
"B", 1 }, { "C", 5 }, {
"D", 2 } };
Would someone please provide an example of a way to do this using lambda expressions.
It seems like it should be pretty simple, but this one has me stumped.
Thanks!