I do programming in C# and I have an array of objects (Called A
). Now I want to have another array which each cell contains an array of A
(Called B
). For example:
B=[A1,A2,A3];
Can someone direct me to the solution?
I do programming in C# and I have an array of objects (Called A
). Now I want to have another array which each cell contains an array of A
(Called B
). For example:
B=[A1,A2,A3];
Can someone direct me to the solution?
As you may know, an array of A
objects is defined as:
A[]
Then, an array of... arrays of A
objects is defined as:
A[][]
You can create it like this:
A[] a1 = new A[10];
A[] a2 = new A[20];
A[] a3 = new A[5];
A[][] b = new A[][] {a1, a2, a3};
You can index either as follows:
var value = b[2][3];
This will get the array at index 2, and element 3 of that array.
> or A[][].
– Pieter Geerkens Mar 07 '13 at 20:41