DEV Community

Discussion on: LINQ SelectMany in Depth

Collapse
 
jessekphillips profile image
Jesse Phillips

If I understand your final index example should look like

books.SelectMany(
   (b, i) => b.Characters[i]...)

Or we could replace the result collector.

books.SelectMany(
   (b, i) => $"{b.Characters[i]} ({b.Title})")
Collapse
 
integerman profile image
Matt Eland

No, what I have there is correct and works properly.

Collapse
 
jessekphillips profile image
Jesse Phillips • Edited

I don't understand where characters comes from then. It looks undefined to me.

Thread Thread
 
integerman profile image
Matt Eland

Imagine it as a List<string> that comes from another file or data source outside of books