You can store multiple variables of the same type in an array data structure. declaring an array by specifying the type of its elements
Type []arrayname;
1 classTestarraysclass2 {3 Static voidMain ()4 {5 //Declare a single-dimensional array one-dimensional arrays6 int[] Array1 =New int[5];7 8 //Declare and set array element values9 int[] Array2 =New int[] {1,3,5,7,9 };Ten One //Alternative Syntax A int[] Array3 = {1,2,3,4,5,6 }; - - //Declare A and dimensional array multidimensional arrays the int[,] multiDimensionalArray1 =New int[2,3]; - - //Declare and set array element values - int[,] MultiDimensionalArray2 = {{1,2,3}, {4,5,6 } }; + - //Declare a jagged array interleaved + int[] Jaggedarray =New int[6][]; A at //Set the values of the first array in the jagged array structure -jaggedarray[0] =New int[4] {1,2,3,4 }; - } -}
Properties of the array:
When an array instance is created, the dimensions and the length of each dimension are established. These values cannot be changed during the lifetime of the instance.
The default value of a numeric array element is set to zero, and the default value of the reference element is set to NULL.
A jagged array is an array of arrays, so its elements are reference types and are initialized to null.
The index of the array is zero-based: The index of an array with n elements is from 0 to n-1.
Array elements can be of any type, including array types
Array Brief (C # Programming Guide)