using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Dictionary<char, int> objDict=new Dictionary<char,int>();
string strStringName = "anandaa";
char[] strchar = strStringName.ToCharArray();
foreach (var charvalue in strchar)
{
int value=1 ;
if (objDict.ContainsKey(charvalue))
{
objDict.TryGetValue(charvalue, out value);
value++;
objDict[charvalue] = value;
}
else
{
objDict.Add(charvalue, 1);
}
}
foreach (KeyValuePair<char, int> kvp in objDict)
{
Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
}
Console.Read();
}
}
}