ToArray
is not necessarily faster than ToList
. Just use ToList
.
The point is as long as you don’t know the number of elements of the original sequence before enumerating, you end up with resizing an array and adding elements to it like a List<T>
does, so ToArray
will have to do the same thing a List<T>
does anyway. Besides, ToList
gives you a List<T>
and that’s nicer than a raw array.
Of course, if you know the concrete type of the IEnumerable<T>
instance, there can be faster methods, but that’s not germane to the point.
Side note: using an array (unless you have to) is arguably a micro-optimization and should be avoided most of the time.