Reputation: 997
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.
Upvotes: 4
Views: 147
Reputation: 152511
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];
Upvotes: 5
Reputation: 98740
From Jagged Arrays (C# Programming Guide)
Before you can use a jagged array, its elements must be initialized.
[5][5,5]
means your jagged array has 5
array which all they are two-dimensional and their dimensions are 5
and 5
.
Upvotes: 2