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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Arun Kumar Balimidi10 reputationPosted Jan 6, 2026, 10:14 AM EST
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);
}
}
}