Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一组部分,每个部分都有一组问题。如果我想选择所有部分下的所有问题,这可行
Sections.SelectMany(s=>s.Questions)
但现在我也想要节号。所以如果我尝试这样的事情
Sections.SelectMany(s=>s.Questions,s.SectionNumber)
它会引发编译错误。
我该如何进行这项工作?
您应该在这里使用匿名类型:
Sections.SelectMany(s => s.Questions, (s, q) => new { Question = q, s.SectionNumber })