[英]Convert Jagged array to several one-dimensional arrays
我想知道是否有一种方法可以将锯齿状数组(例如[3][]
转换为三个一维数组?
Something like this? 像这样吗 Assuming
jagged
is defined as int[3][]
: 假设
jagged
定义为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. jagged
的第一维中的每个元素本身就是一个数组-无需转换。
It already is three one-dimensional arrays, effectively. 有效地,它已经是三个一维数组。 Jagged arrays are not treated specially by the CLR, they are simply arrays of arrays.
锯齿状数组不是CLR特意处理的,它们只是数组的数组。 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];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.