Counting words in a collection using LINQ
Posted
by icemanind
on Stack Overflow
See other posts from Stack Overflow
or by icemanind
Published on 2010-06-11T22:10:22Z
Indexed on
2010/06/11
22:12 UTC
Read the original article
Hit count: 283
Guys,
I have a StringCollection object with 5 words in them. 3 of them are duplicate words. I am trying to create a LINQ query that will count how many unique words are in the collection and output them to to the console. So, for example, if my StringCollection has 'House', 'Car,'House','Dog', 'Cat', then it should output like this:
House --> 2 Car --> 1 Dog --> 1 Cat --> 1
any ideas on how to create a LINQ query to do this?
© Stack Overflow or respective owner