LINQ · interview question
Which LINQ method projects each element to a sequence and flattens the results into one sequence? (method name only)
Fill in the blankMedium
Answer and explanation
Correct answer
SelectMany or SelectMany() or .SelectMany
Why
SelectMany maps each element to an IEnumerable and concatenates them, e.g. orders.SelectMany(o => o.Lines) gives every order line across all orders.
Test yourself on LINQ
A free test with instant, explained results. No account needed.