I have an array which contains the following results
red
red
red
blue
blue
Green
White
Grey
and I want to get duplicate count of every val
I think this should do the trick
string[] arr = { "red", "red", "blue", "green", "Black", "blue", "red" };
var results = from str in arr
let c = arr.Count( m => str.Contains(m.Trim()))
select str + " count=" + str;
foreach(string str in results.Distinct())
Console.WriteLine(str);
Output:
red count=3
blue count=2
green count=1
Black count=1