I have an array of ordered enumerables IorderedEnumerable<T>[] foo
and I want to flatten it so that the ordered enumerables of foo
are concatenated together in the order they are stored in the array.
For example {{1, 2, 3}, {4, 5}, {6}} => {1, 2, 3, 4, 5, 6}
Can I do this by IOrderedEnumerable<T> bar = foo.SelectMany(x => x);
, or does LINQ not guarantee how order is handled when flattening?
All LINQ to Objects methods (except, obviously, OrderBy()
and ToDictionary()
) will preserve source ordering.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With