【发布时间】:2010-12-31 11:38:27
【问题描述】:
我需要确定Dictionary 中包含的任何Lists 是否包含指定值。我是 LINQ 新手,那么以下是实现此目的的正确方法吗?
Dictionary lotsOfStuff = new Dictionary<string, List<string>>();
string searchString;
// populate lotsOfStuff and searchString...
// detemine if any of the values of lotsOfStuff contain searchString
bool existsInDictionary = lotsOfStuff.Values.Any(values => values.Contains(searchString));
如果上述方法可行,有什么方法可以使它更正确或更优化/简洁?
【问题讨论】:
标签: c# linq .net-3.5 linq-to-entities