How to copy First row of 3D array to a 2D array

  • Thread starter Thread starter Silvers11
  • Start date Start date
S

Silvers11

Guest
Hello!

I have a 3 dimensional Array (array3D)

As seen in the example I have put the numbers: 12,13,14 to the first row/dimension (0)

Now I wonder how it would be possible to copy this first dimension to a 2 dimensional Array: (array2D) ?


Notice that I don't want to loop but wonder if there is any faster way. I am actually looking for the fastest possible way to do this as this is a part of a micro-optimizing code.

I know the .CopyTo method is extremely fast but unfortenately it seems to only work on Single Dimension arrays?

Thank you!

byte[,,] array3D = new byte[4, 10, 10];
array3D[0, 0, 0] = 12;
array3D[0, 0, 1] = 13;
array3D[0, 0, 2] = 14;


byte[,] array2D = new byte[10, 10];
array3D.CopyTo(array2D, 0); //.CopyTo doesn't work. It only works for Single dimension arrays

Continue reading...
 
Back
Top