Count Number of Occurrences of Each Character in a?
String
Dictionary<char, int> CountCharacters(string s)
var dict = new Dictionary<char, int>();
foreach (char c in s)
if (dict.ContainsKey(c))
dict[c]++;
else
dict[c] = 1;
return dict;
Explanation:
Simple frequency map using Dictionary.