我有一个循环如下:
foreach(x in myColl)
{
foreach(var y in x.MyList)
{
result.Add(x.MyKey + y)
}
}
Run Code Online (Sandbox Code Playgroud)
这意味着在我的内部循环中,我需要访问当前外部元素的属性.
我正在寻找LINQ声明,但我不确定.我试过用它
result = myColl
.SelectMany(x => x.MyList)
.SelectMany(x => /* how to get the key of the outer loop here */ + x)
Run Code Online (Sandbox Code Playgroud)