I'm trying to paste an array of custom class instances into a 2d array of them in a specific position with this code:
arr.Array.SetValue(stripe, topleft.X, topleft.Y);
…and it gives me a System.InvalidCastException with the message Object cannot be stored in an array of this type.
arr.Array is MyClass[,], and stripe is MyClass[].
What am I doing wrong here?
This line of code is a part of a larger method that loads a rectangular piece of map for a 2d platformer. The goal is to load separate stripes of tiles into a 2d array so that they form a rectangle of certain dimensions within the 2d array of tiles of larger dimensions.
Of course, this can be done bit by bit, but isn't there some method that allows to do that?
MyClass[,][]instead.topleft.