What is an Array? Give the syntax for a single and multi-dimensional array in C#?
- An Array is used to store multiple variables of the same type. It is a collection of variables stored in a contiguous memory location.
- For Example:
- double numbers = new double[10];
- int[] score = new int[4] {25,24,23,25};
- A Single dimensional array is a linear array where the variables are stored in a single row. Above example is a Single dimensional array.
- Arrays can have more than one dimension. Multidimensional arrays are also called rectangular arrays.
- For Example, int[,] numbers = new int[3,2] { {1,2} ,{2,3},{3,4} };
No comments