array of arrays

  • Thread starter Thread starter george r smith
  • Start date Start date
G

george r smith

In delphi you could have
Type board[0..63][records].

I think structs would replace records but
how can you do this in c# ?

I can not even get this to work
int[][] a = new int[5][5];

I did not think you could do arrays of arrays
in C# but it is mentioned in Hejlsberg new book on page 10.
"..int[][] is a single-dimensinal array of single
dimensional arrays of int."

Thanks
grs
 
george r smith said:
In delphi you could have
Type board[0..63][records].

I think structs would replace records but
how can you do this in c# ?

I can not even get this to work
int[][] a = new int[5][5];

For some reason, C# doesn't allow jagged arrays (arrays of arrays) to
be initialised like that. You can do:

int[][] a = new int[5][];
for (int i=0; i < a.Length; i++)
{
a = new int[5];
}

Do you definitely want a jagged array though, or would a rectangular
array be okay? If so:

int[,] a = new int[5,5];

would work.
 
Back
Top