Add dimension to multidimensional array in C #

I have a multidimensional array

byte[,] matrix; 

and I want to copy to an array of size 3

 byte[,,] 3dplan; 

thus

 3dplan[,,0]=matrix 

What is the fastest way to accomplish this task in C #?

+6
source share
1 answer

You need to manually copy the elements in a nested loop; there is no faster way.

If you switch to an uneven array ( byte[,][] or byte[][][] ), you can insert a smaller as-is array into the slot of the larger array (although both of them will refer to the same array instance and will select the changes)

+5
source

Source: https://habr.com/ru/post/887738/


All Articles