Answer the question
In order to leave comments, you need to log in
Multidimensional array, why didn't the piece of code work?
int[,] array2 = new int[10,10];
array2 [10,9] = 1299;
Console.WriteLine (array2[10,9]);
Answer the question
In order to leave comments, you need to log in
Because int[,] array2 = new int[10,10]; is an array with cells from array2[0,0] to array2[9,9]
Numbering starts from 0. That is, the first cell of a 10 by 10 array will be array2[0,0], and the last cell will be array2[9,9].
And you are trying to refer to a non-existent cell ([10,9]), so you get an error that you have out of range of the array.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question