有人可以帮我添加下面代码段中评论的if语句吗?如何在LINQ语句中添加if语句
Dictionary<string,int> toReturn;
List<string> lookup = GetIt();
foreach (string test in lookup)
{
var testDictionary = ToGroupDictionary(test);
testDictionary.Keys.ToList().ForEach(k =>
//if(true){add toReturn list}
);
}
你会更好只使用一个'foreach'环 - ['.ForEach '实际上是一个弃用的构造](http://stackoverflow.com/questions/10299458/is-the-listt-foreach-extension-method-gone)。 –