Dictionarydic = new Dictionary ();
String s = "12342212213244";
char[] chardata = s.ToCharArray();
foreach (char c in chardata)
{
if (!dic.ContainsKey(c))
{
dic.Add(c, 1);
}
else
{
dic[c] = dic[c] + 1;
}
}
foreach (KeyValuePairitem in dic)
{
Console.WriteLine("{0}出现{1}次", item.Key, item.Value);
}
Console.ReadLine();