[Solved] I want to know the count of each item in a list
You can use GroupBy: var voteGroups = Votes.GroupBy(s => s); Now, if you want to know the count of each string use Enumerable.Count: foreach(var voteGroup in voteGroups) Console.WriteLine(“Vote:{0} Count:{1}”, voteGroup.Key, voteGroup.Count()); Another way is using ToLookup: var voteLookup = Votes.ToLookup(s => s); foreach (var voteGroup in voteLookup) Console.WriteLine(“Vote:{0} Count:{1}”, voteGroup.Key, voteGroup.Count()); The lookup has it’s … Read more