【发布时间】:2014-07-20 18:54:39
【问题描述】:
我的代码在这里:
string[] Lines = File.ReadAllLines(textBox1.Text);
List<string> NewLines = new List<string>();
foreach (string Line in Lines)
{
string newLine = Line.Trim();
if (!NewLines.Exists(newLine))
NewLines.Add(newLine);
NewLines.Exists() 函数产生这个错误:
System.Collections.Generic.List<string>.Exists(System.Predicate<string>) 的最佳重载方法匹配有一些无效参数
【问题讨论】:
-
我真的相信阅读 MSDN 文档应该足以回答此类问题......
-
如果你的文件很大,我可以建议使用
HashSet<string>吗? -
如果您将所有变量名驼峰化,代码的可读性会好得多。