I have a multi-dimensional Array with unknown dimensions at compile time but at runtime (when i receive such Array) its dimension are described int[] dimensions. The length of dimensions is equal to the Rank of the Array and each element of dimensions contains the length of the relevant dimension.
What i want to obtain is a similar Array whose elements are mapped in a new object with a different type. I thought that LINQ could be useful so i wrote the following:
Array arr = ... //My multi-dimensional Array
var dimensions = ... //array describing the dimensions of arr. (NOT USED in the following but is an information i have)
var transformedArr = arr.Cast<StatusCode>().Select(val => JObject.FromObject(val)).ToArray();
It works but transformedArr is just a one-dimension Array now, hence i lost my multi-dimensional matrix.
Have you got any idea to obtain a same Array with different element type only?
Please, note that i don't know a priori the dimensions of the array, only at runtime. In other words i can't use loops for indexing the multi-dimensional Array.
Any idea will be appreciated :)