[英]Address a single row of a 2-dimensional array?
Is there any way in c# to address a single row of a 2-dimensional array? c#中有什么方法可以解决二维数组的单个行?
I want to be able to pass one-dimension of a 2 dimensional array as a parameter and sometimes I want to pass the whole 2-dimentional array. 我希望能够传递二维数组的一维作为参数,有时我想传递整个二维数组。
You can use jagged arrays. 您可以使用锯齿状数组。
Example based on the code in Jagged Arrays (C# Programming Guide) : 基于锯齿数组(C#编程指南)中的代码的示例:
int[][] jaggedArray = new int[3][];
jaggedArray[0] = new int[5];
jaggedArray[1] = new int[4];
jaggedArray[2] = new int[2];
// To pass the whole thing, use jaggedArray
// To pass one of the inner arrays, use jaggedArray[index]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.