using System;
using System.Linq;
public class Program
{
public static void Main()
{
string str= "C# program to count the occurrences of each character".ToLower();
var charcount = (from c in str
group c by c into g
select new
{
c = g.Key,
count = g.Count(),
}).OrderByDescending(c => c.count);
foreach (var data in charcount)
{
Console.WriteLine(data.c + ":" + data.count);
}
}
}

0 Comments