我正在尝试做一个字典游戏,我有一个文本文件,每行大约有100,000个单词。我有这样的代码:
words = new List<Word>();
Console.WriteLine("Please wait, compiling words list...");
TextReader tr = new StreamReader(DICT);
string line = tr.ReadLine();
while (line != "" && line != null) {
words.Add(new Word(line));
line = tr.ReadLine();
}
Console.WriteLine("List compiled with " + words.Count + " words.");然而,它止步于40510个单词。为什么会这样呢?我该如何解决这个问题呢?
谢谢。
发布于 2010-07-29 01:55:14
编辑:对不起;我在记事本中检查了空行,但没有找到;在Notepad++中搜索也找到了它们。
我的错,还是要谢谢你。
发布于 2010-07-29 01:55:09
它是停止还是抛出异常?在Console.WriteLine调用之前检查调试器中的line变量值,可能是空行。
发布于 2010-07-29 01:56:02
问题出在您的线路上!= "“请检查。去掉它,它就会继续。
https://stackoverflow.com/questions/3355825
复制相似问题