Let’s say that I have an ArrayList of MyObject instances.
ArrayList.ToArray() returns an array of object ( object[] ). Now I want to cast the object[] to MyObject[] without creating a new array.
This throws a InvalidCastException:
(MyObject[])arrayList.ToArray()
And this always returns null:
arrayList.ToArray() as MyObject[]
Any other ideas?
Thanks.