Content
To assign values to the array:
int[] numbers = new int[] {1, 2, 3, 4, 5};
And to access an element in the array, use the index of that element (keep in mind that
indexing starts at 0):
int[] numbers = new int[] {1, 2, 3, 4, 5};
Console.WriteLine(numbers[0]);
// Output: 1
Practice
Fill in the code to create an integer array called nums that holds numbers from 1 through
5:
???[] ??? = new int[] {???};
int
nums
1, 2, 3, 4, 5
1-5
integers
numbers
Revision
Fill in the code to output the number 7 from the numbers array using its index:
int[] numbers = new int[] {1, 3, 5, 7, 9, 11};
Console.WriteLine(numbers[???]);
// Output: 7
3
7
4
1