Jitendra Kumar
i have a string like "Nitin" write a method or logic to get output like this this N=2 I=2 T=1 means char count in string.
By Jitendra Kumar in .NET on Dec 09 2014
  • Vaibhav Salwe
    May, 2015 30

    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();}}

    • 0
  • Pankaj  Kumar Choudhary
    May, 2015 27

    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]);

    • 0
  • Venkataramana Mulumudi
    Dec, 2014 26

    Awesome Harish

    • 0
  • Harieswaran D
    Dec, 2014 18

    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);}

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS