using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
try
{
string[] Lines=File.ReadAllLines("C:\\Demo.txt");
for(int i=0;i<Lines.Length;i++)
{
Dictionary<string, int> result = new Dictionary<string, int>();
foreach (char chr in Lines[i].ToCharArray())
{
if (result.ContainsKey(chr.ToString()))
result[chr.ToString()] += 1;
else
result.Add(chr.ToString(),1);
}
string end=string.Format("第{0}è¡ï¼",i+1);
foreach(KeyValuePair<string, int> kvp in result)
{
end+=string.Format("[{0}]ååºç°äº{1}次,\t",kvp.Key,kvp.Value);
}
Console.WriteLine(end);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
}
}
æ§å¶å°çï¼ï¼
èªå·±å¨Cç建ç«ä¸ä¸ªDemo.txt æ件ï¼ç¶åå¨éé¢è¾å
¥æ±åä¿åï¼ç¶åæ代ç å¤å¶å°ä½ çå·¥ç¨ä¸å»ç¼è¯æ§è¡ççï¼ä»
ä¾åèå·ï¼ï¼