Does anyone know of an efficient way to flatten a 2d array (non-jagged) in C# to a 1d and back again. I know in the back end C# must hold onto it as a 1d array I would just
var myFlattenedByteArray = my2DByteArray.SelectMany(b=>b).ToArray();
This will return each element of each subarray of the 2D byte array in subarray-element order: myFlattenedByteArray[1] == my2DByteArray[0][1]. There are probably more performant or efficient solutions (especially the slupring of the Enumerable produced by SelectMany into its own Array) but it's a one-liner.