You do not need to specify a type argument for the ToArray method; it must be inferred from its use if you use strongly typed collections. This is a typical casting problem. You are trying to put elements into an array of some incompatible type.
Your problem should boil to this (these arrays are covariant):
object[] obj = new string[1]; obj[0] = 5; // compiles fine, yields runtime error
Now the same thing, with different types (these arrays are also covariant):
IEnumerable<int>[] x = new List<int>[1]; x[0] = new int[1]; // compiles fine, yields runtime error
Obviously, why the type system is not like. Basically, you look at it as an IEnumerable<int> array, but it's actually a List<int> array. You cannot put an array of int types into an unrelated array.
I believe Eric Lippert explains this very well on the blog .
source share