Hi all ,
I wonder if there's a way to convert jagged array , say [3][]
into three one-dimensional arrays ?
views:
44answers:
2
+2
A:
Something like this? Assuming jagged
is defined as int[3][]
:
int[] first = jagged[0];
int[] two = jagged[1];
int[] three = jagged[2];
Each element in the first dimension of jagged
is an array in and of itself - there is no need to convert.
Oded
2010-07-10 17:50:13
+1
A:
It already is three one-dimensional arrays, effectively. Jagged arrays are not treated specially by the CLR, they are simply arrays of arrays. You just index the outer array to get one of the inner arrays.
Example:
var array1 = jaggedArray[0];
var array2 = jaggedArray[1];
var array3 = jaggedArray[2];
Noldorin
2010-07-10 17:50:22