Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Dictionary<char, int> Count(string value)
- {
- var dictionary = new Dictionary<char, int>();
- char[] chars = value.ToCharArray();
- for (int i = 0; i < chars.Length; i++)
- {
- if (dictionary.ContainsKey(chars[i]))
- {
- dictionary[chars[i]]++;
- }
- else
- {
- dictionary.Add(chars[i], 1);
- }
- }
- return dictionary;
- }
Advertisement
Add Comment
Please, Sign In to add comment