class Program{static void Main(string[] args){int cnt = 0; int occ = 0;Console.WriteLine("Enter string");string str = Console.ReadLine();char[] newstr = str.Distinct().ToArray();for (int i = 0; i < newstr.Length; i ){cnt = 0; occ = 0;while (cnt < str.Length){if (newstr[i] == str[cnt]) { occ ; }cnt ;}Console.WriteLine(" {0} = {1} ", newstr[i], occ);}Console.ReadLine();}}
string str = "nitin"; var Mylsit = str.GroupBy(e => e).Select(g => new { g.Key, Count = g.Count() }).ToList(); Console.WriteLine(Mylsit[0]); Console.WriteLine(Mylsit[1]); Console.WriteLine(Mylsit[2]);
Awesome Harish
var resultList = input.GroupBy(e => e).Select(g => new {q = g.Key.ToString().ToUpper() "-" g.Count().ToString() }).ToList();foreach (var item in resultList){Console.WriteLine(item.q);}