score:2

Accepted answer

You must use SelectMany.

If you use Select, then you get a Enumerable<List<Node>>, with SelectMany, you get only a List<Node>

List<Node> exitNodes = gateways.SelectMany(gw => gw.Connections).Select(node => node).ToList();

The answer in this post explains the difference between SelectMany and Select: https://stackoverflow.com/a/959057/5056173


Related Articles