Convert Jagged array to several one-dimensional arrays
I wonder if there's a way to convert jagged array , say开发者_高级运维 [3][]
into three one-dimensional arrays ?
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.
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];
精彩评论