0

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?

Michael Berkowski
  • 260,803
  • 45
  • 432
  • 377

1 Answers1

1

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.

Daniel A.A. Pelsmaeker
  • 43,952
  • 19
  • 106
  • 152