using System.Collections.Generic;
public static void Main()
Console.WriteLine("Please enter your string:");
userInputString = Console.ReadLine().ToUpper();
Dictionary <char, int> CountOfAlphabets = new Dictionary <char, int> ();
createAlphabetDictionary( ref CountOfAlphabets);
int totalLettersCounted = CountAlphabetsAndReturnTotalValidLetters(userInputString, ref CountOfAlphabets);
DisplayTabulate(false , ref CountOfAlphabets);
DisplayTabulate(true , ref CountOfAlphabets);
Console.WriteLine("\n The text has been processed. Total letters counted: [{0}] " , totalLettersCounted);
public static void createAlphabetDictionary (ref Dictionary <char, int> CountOfAlphabets)
for(char c = 'A'; c <= 'Z'; c++)
CountOfAlphabets.Add(keyOfAlphabet, 0);
public static int CountAlphabetsAndReturnTotalValidLetters(string _userInputString, ref Dictionary <char, int> CountOfAlphabets)
int _totalLettersCounted = 0;
foreach (char i in _userInputString)
if (CountOfAlphabets.ContainsKey(i))
CountOfAlphabets.TryGetValue(i, out currentCount);
CountOfAlphabets[i] = currentCount + 1;
return _totalLettersCounted;
public static void DisplayTabulate (bool isValue, ref Dictionary <char, int> CountOfAlphabets)
foreach (var a in CountOfAlphabets)
Console.WriteLine ("\n____________________________________________________");