I have this problem with my output of this code which outputs how many times a character in a string is mentioned.
class Program
{
static void Main(string[] args)
{
string str = Console.ReadLine().ToLower();
string sortedString = String.Concat(str.OrderBy(c => c));
foreach (char ch in sortedString)
{
Console.WriteLine($"{ch} => {str.Count(x => x == ch)}");
}
}
}
This is the output I get:
Alabala
a => 4
a => 4
a => 4
a => 4
b => 1
l => 2
l => 2
This is the output I want to get
Alabala
a => 4
b => 1
l => 2
Would appreciate if somebody helps me out.