 int[] numbers = new int[2];
numbers[0] = 2;
numbers[1] = 5;
int x = numbers[0];


Array initializers provide convenient syntax for initialization of arrays.// Long syntax
int[] numbers = new int[5]{ 20, 1, 42, 15, 34 };
// Short syntax
int[] numbers2 = { 20, 1, 42, 15, 34 };
// Inferred syntax
var numbers3 = new[] { 20, 1, 42, 15, 34 };


Arrays can have more than one dimension, for example 2 dimensions to represent a grid.int[,] numbers = new int[3, 3];
numbers[1,2] = 2;

int[,] numbers2 = new int[3, 3] { {2, 3, 2}, {1, 2, 6}, {2, 4, 5} };


See also

Classes are self-describing user-defined reference types.