有人可以帮我添加下面代码片段中注释的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}
);
}
答案 0 :(得分:4)
只需要添加花括号:
testDictionary.Keys.ToList().ForEach(k =>
{
//if(true){add toReturn list}
});
答案 1 :(得分:3)
或添加Where
子句
testDictionary
.Keys
.Where(k => conditional(k))
.ForEach(k => { /* something else */ } );