Declaring Arrays
Create and fill an array.
What Is an Array?
An array stores many values of the same type in one variable. Instead of score1, score2, score3, you keep all scores together.
Arrays have a fixed size that you set when you create them. They are perfect for lists like days of the week or test results.
Declaring an Array Type
To declare an array you write the element type followed by square brackets [], then the name.
This just creates the variable. It does not hold any values yet, so it is null until you give it an array.
int[] numbers;
string[] names;All lessons in this course
- Declaring Arrays
- Indexing and Length
- Looping Over Arrays
- Multidimensional Arrays