Split comma separated string to count duplicates
Posted
by josepv
on Stack Overflow
See other posts from Stack Overflow
or by josepv
Published on 2010-04-11T17:13:55Z
Indexed on
2010/04/11
17:33 UTC
Read the original article
Hit count: 283
c#
I have the following data in my database (comma separated strings):
"word, test, hello"
"test, lorem, word"
"test"
...
etc
How can I transform this data into a Dictionary whereby each string is separated into each distinct word together with the number of times that it occurs, i.e.
{"test", 3}, {"word", 2}, {"hello", 1}, {"lorem", 1}
I will have approximately 3000 rows of data in case this makes a difference to any solution offered. Also I am using .NET 3.5 (and would be interested to see any solution using linq)
© Stack Overflow or respective owner