C# 分布式查询大数据? 比如一个txt 有1G 我先查出来每个汉字出现的次数,有办法吗?
1条回答 默认 最新
threenewbee 2016-07-22 09:50关注Dictionary<string, int> dict = new Dictionary<string, int>(); fileStream = new FileStream(你的文件, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fileStream, Encoding.你的文件编码); string content = sr.ReadLine(); while(content != null) { content = sr.ReadLine(); foreach (var c in content) { if (!dict.ContainsKey(c)) dict.Add(c, 0); dict[c]++; } }解决 无用评论 打赏 举报