using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SchoolDays
{
class Program
{
static void Main(string[] args)
{
string InputString = "aaabbbdsdbnkaaa sdf sdf ftgh ";
string Result;
var common = InputString.Intersect(InputString);
for (int index = 0; index < common.Count(); index++)
{
int TotalStrOccurences = InputString.Count(f => f == common.ElementAt(index));
Result = (common.ElementAt(index).ToString() != " ") ? common.ElementAt(index).ToString() : "Empty Space";
Console.WriteLine(Result + " : " + TotalStrOccurences);
}
Console.ReadKey();
}
}
}Output
a: 6
b : 4
d : 4
s : 3
n : 1
k : 1
Empty Space : 4
f : 3
t : 1
g :1
h : 1
