Recall & Review
beginner
What is a multi-dimensional array in C#?
A multi-dimensional array is an array with more than one dimension, like a table with rows and columns. It stores data in a grid-like structure.
Click to reveal answer
beginner
How do you declare a 2D array of integers with 3 rows and 4 columns in C#?
You declare it like this: <br>
int[,] array = new int[3,4];<br>This creates a grid with 3 rows and 4 columns.Click to reveal answer
beginner
How do you access the element in the 2nd row and 3rd column of a 2D array named
array?Use
array[1, 2] because indexing starts at 0. So row 2 is index 1, column 3 is index 2.Click to reveal answer
intermediate
What is the difference between a rectangular array and a jagged array in C#?
A rectangular array has rows and columns all the same size (like a grid). A jagged array is an array of arrays where each row can have different lengths.
Click to reveal answer
beginner
How can you loop through all elements of a 2D array in C#?
Use two nested loops: one for rows and one for columns. For example:<br>
for (int i = 0; i < rows; i++) {<br> for (int j = 0; j < cols; j++) {<br> // access array[i, j]<br> }<br>}Click to reveal answer
How do you declare a 3D array of doubles with dimensions 2x3x4 in C#?
✗ Incorrect
In C#, multi-dimensional arrays use commas inside square brackets. So
double[,,] declares a 3D array.What is the index of the first element in any dimension of a C# array?
✗ Incorrect
C# arrays are zero-indexed, so the first element is always at index 0.
Which of these is a jagged array declaration in C#?
✗ Incorrect
Jagged arrays are arrays of arrays, declared with multiple square brackets like
int[][].How do you find the number of rows in a 2D array named
arr?✗ Incorrect
GetLength(0) returns the size of the first dimension (rows) in a multi-dimensional array.What will happen if you try to access
array[3,0] in a 3x4 array?✗ Incorrect
Index 3 is out of range for rows (0 to 2), so it throws an exception.
Explain how to declare, initialize, and access elements in a 2D array in C#.
Think of a table with rows and columns.
You got /4 concepts.
Describe the difference between rectangular and jagged arrays and when you might use each.
Imagine a perfect grid vs. uneven shelves.
You got /4 concepts.