Reputation: 33
How can I get List<IMyType>
from List<Tuple<int, List<IMyType>>>
var result = alg.Result; // Result return List<Tuple<int, List<IMyType>>>
List<IMyType> list = ???
Upvotes: 1
Views: 2950
Reputation: 39013
@Servy's answer is the best way to do that. Just keep in mind that if you don't remember the LINQ way of doing things, you can always do it the old way:
var list = new List<IMyType>();
foreach(var tuple in result)
list.AddRange(tuple.Item2);
Upvotes: 2
Reputation: 203814
SelectMany
is used to transform each item in the collection to a sequence of something else, and then to flatten that sequence:
var flattenedSequence = list.SelectMany(pair => pair.Item2);
Upvotes: 4