我有Dictionary<string,List<Member> members
,并且我有foreach循环。如何隐式循环到linq表达式中?
members.Foreach(x => x.Where(a=>a.Firstaname ?
foreach (var key in games.Keys)
{
foreach (var val in games[key])
{
if (firstName == val.FirstName && lastName == val.LastName && command == val.CommandName)
{
val.Position = position;
}
}
}
如果它与词典中的数据匹配,则需要设置玩家的位置
答案 0 :(得分:2)
var items = games.SelectMany(x => x.Value).Where(val => firstName == val.FirstName && lastName == val.LastName && command == val.CommandName);
foreach(var i in items)
{
i.Position = position;
}