Reputation: 19
Is there any way in c# to address a single row of a 2-dimensional array?
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.
Upvotes: 1
Views: 249
Reputation: 499132
You can use jagged arrays.
Example based on the code in Jagged Arrays (C# Programming Guide):
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]
Upvotes: 1