【发布时间】:2010-07-28 15:45:10
【问题描述】:
我有一个通用的List,我必须在这个列表中找到一个特定的字符串。您能否告诉我以下哪种方法最好?
if (strlist.Contains("Test"))
{
// String found
}
或
string res = (from d in strlist where d == "Test" select d).SingleOrDefault();
if (res == "Test")
{
//found
}
请考虑从数据库中填充的列表可能非常大。非常感谢您对此的想法。
【问题讨论】:
-
必填项:您是否进行过测试和测量?