Code using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; namespace StringTest { class Program { staticvoid Main(string[] args) { string d = FindMaxChar("ABCDADCCCA"); } privatestaticstring FindMaxChar(string value) { //compute the numbers of each char and store it in hashTable Hashtable ht =new Hashtable(); for (int i =0; i < value.Length; i++) { if (!ht.ContainsKey(value.Substring(i, 1))) { ht.Add(value.Substring(i, 1), GetCount(value, value.Substring(i, 1))); } } int temp; string maxStr =string.Empty; List<int> lt =new List<int>(); foreach (System.Collections.DictionaryEntry objDE in ht) { lt.Add(Convert.ToInt32(objDE.Value)); } //get the max Num. for (int i =0; i < lt.Count -1; i++) { if (lt[i] > lt[i +1]) { temp = lt[i +1]; lt[i +1] = lt[i]; lt[i] = temp; } } //get the max char. foreach (System.Collections.DictionaryEntry objDE in ht) { if (objDE.Value.ToString() == lt[lt.Count -1].ToString()) { maxStr = objDE.Key.ToString(); } } return maxStr; } //get the count of char. privatestaticint GetCount(string orignal, string strTarget) { int count =0; for (int i =0; (i = orignal.IndexOf(strTarget, i)) >=0; i++) { count++; } return count; } } }