views:

44

answers:

2

Hi all , I wonder if there's a way to convert jagged array , say [3][] into three one-dimensional arrays ?

+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
+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