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?

1
  • Two possibilities: List<List<A>> or A[][]. Commented Mar 7, 2013 at 20:41

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.