- Home /
Copying a multidimensional array
I have 2 multidimensional array, both of the same size. I need to copy the content from one to another. Is there a better way for doing that than this one??
for(var i : int = 0; i < cols; i++) {
for(var j : int = 0; j < rows; j++) {
myArr1[i][j] = myArr2[i][j];
}
}
EDIT: Im using JS.
Answer by Eric5h5 · May 16, 2012 at 07:13 PM
System.Array.Copy (myArr1, myArr2, myArr1.GetLength(0)*myArr1.GetLength(1));
BCE0023: No appropriate version of 'System.Array.Copy' for the argument list '(Array, Array, System.Object)' was found.
Im using JS. I forgot to mention :)
So am I (it's obvious from your code). I guess you're not actually using multidimensional arrays, ins$$anonymous$$d you are using Arrays of Arrays. Which is bad. ;) Use multidimensional arrays ins$$anonymous$$d.
Looked in my code. Im using arrays of arrays. Im going to look how to change it! Thanks! :)
Why is it bad to use arrays of arrays?
There are some cases where it is useful...
Your answer
Follow this Question
Related Questions
Having Multiple Controllable FPS Units Selected From A Singular RTS Mode? 0 Answers
Problems with Arrays 2 Answers
Array Within Index 1 Answer
my QandA array is not working when you choose 3 wrong answers 1 Answer
Array empties values on RunTime? 1 Answer