For example string input = "developer";
output :
d - 1
e - 3
v - 1
l - 1
like wise
For example string input = "developer";
output :
d - 1
e - 3
v - 1
l - 1
like wise
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Arun Kumar BalimidiPosted Jan 6, 2026, 3:14 PM
using System;
using System.Collections.Generic;
public class HelloWorld
{
public static void Main(string[] args)
{
string input="Hello World";
Dictionary charcnt=new Dictionary();
foreach(char c in input)
{
if(charcnt.ContainsKey(c))
{
charcnt[c]++;
}
else{
charcnt[c]=1;
}
}
foreach(var item in charcnt)
{
Console.WriteLine ( item.Key+" - "+item.Value);
}
}
}