简体   繁体   中英

Add a dimension to a multidimensional array in c#

I have a multidimensional array

byte[,] matrix;

and i want copy in a 3 dimension array

byte[,,] 3dplan; 

in this way

3dplan[,,0]=matrix

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

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

If you switch to a jagged array ( byte[,][] or byte[][][] ), you can insert the smaller array as-is into a slot in the larger array (although they will both refer to the same array instance and will pick up changes)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM