Complete the code to declare an array of 5 integers.
int[] numbers = new int[[1]];The array size must be a positive integer. Here, 5 creates an array with 5 elements.
Complete the code to access the first element of the array.
int first = numbers[[1]];Array indexing in C# starts at 0, so the first element is at index 0.
Fix the error in the code to avoid an IndexOutOfRangeException.
int value = numbers[[1]];The last valid index in an array of size 5 is 4 (since indexing starts at 0). Using 5 or more causes an exception.
Fill both blanks to create a loop that safely accesses all elements of the array.
for (int i = [1]; i [2] numbers.Length; i++) { Console.WriteLine(numbers[i]); }
The loop starts at index 0 and runs while i is less than numbers.Length to avoid going out of bounds.
Fill all three blanks to create a dictionary comprehension that maps each number to its square if the number is less than 5.
var squares = numbers.Where(n => n [1] 5).ToDictionary(n => n, n => n [2] [3]);
The code filters numbers less than 5, then creates a dictionary mapping each number to its square (n * n).