Does LINQ have any native support for splitting a collection in 1 linear pass?
There are no built-in methods that split a collection into two versions based on a predicate. You would need to use your own method, similar to the one you posted.
The closest built-in method would be GroupBy
(or ToLookup
). You could group by odd or even:
var groups = nums.GroupBy(i => IsEven(i));
This will split into two “groups” based on whether the numbers are odd or even.