Complete the code to declare a 2D array of integers with 3 rows and 4 columns.
int[,] matrix = new int[[1], 4];
The first dimension is the number of rows, which is 3 here.
Complete the code to assign the value 10 to the element in the second row and third column of the 2D array.
matrix[[1], 2] = 10;
Array indices start at 0, so the second row is index 1.
Fix the error in the code to correctly declare and initialize a 2D array with 2 rows and 3 columns filled with zeros.
int[,] grid = new int[[1], 3];
The array should have 2 rows and 3 columns, so the first dimension is 2.
Fill both blanks to create a nested loop that prints all elements of a 2D array named 'data'.
for (int i = 0; i < data.GetLength([1]); i++) { for (int j = 0; j < data.GetLength([2]); j++) { Console.WriteLine(data[i, j]); } }
GetLength(0) returns the number of rows, GetLength(1) returns the number of columns.
Fill all three blanks to create a 2D array 'table' with 2 rows and 3 columns, assign 5 to the first element, and print it.
int[,] table = new int[[1], [2]]; table[0, 0] = [3]; Console.WriteLine(table[0, 0]);
The array has 2 rows and 3 columns, so dimensions are 2 and 3. The value 5 is assigned to the first element.