Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jagged Array of 2d arrays error

I try to write an int-Array, but

why I can't write:

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

and how can I write a similar Jagged int as above.

like image 404
Matt126 Avatar asked Mar 21 '23 13:03

Matt126


1 Answers

For a jagged array you need to initialize each array separately:

int[][,] JaggedInt = new int[5][,];
for(int i = 0; i < 5; i++)
    JaggedInt[i] = new int[5,5];

if it were a 3-dimensional array instead of a jagged array you could do:

int[,,] JaggedInt = new int[5,5,5];
like image 68
D Stanley Avatar answered Apr 06 '23 06:04

D Stanley