Count a Char Number of Times in a String

code

C# Code

  1. public ActionResult GetRepeatedCharactorCount(string enterdString)  
  2. {  
  3. string inputString = enterdString;  
  4.        List<string> resultStringList = new List<string>();  
  5.        char[] chrs = inputString.ToCharArray();  
  6.        for (int i = 0; i < chrsList.Length; i++)  
  7.        {  
  8.         int j = 0, count = 0;  
  9.               while ((j = inputString.IndexOf(chrsList[i], j)) != -1)  
  10.               {  
  11.                 count++;  
  12.                         j++;  
  13.               }  
  14.               var outputting = string.Format("{0} Number of times repeat : {1} in                   {2}", chrsList[i], count, inputString);  
  15.               if (resultStringList.IndexOf(outputString) == -1)  
  16.               {  
  17.                 resultStringList.Add(outputString);  
  18.               }  
  19.        }  
  20.        return Json(new { result = resultStringList}, JsonRequestBehavior.AllowGet);  
  21. }  
index