How do you declare and initialize an array in C#(CSharp) Programming Language?
Arrays are variables used to store similar data types grouping as a single unit. It is the collection of variables of the same type stored at contiguous memory locations. The lowest memory address corresponds to the first element and the highest memory address to the last element. C# (CSharp) is a multiparadigm programming language. This step by step tutorial will help you to learn how to declare an array in C# (CSharp) Programming language.
C# Array Declaration :
data_type is the type of elements in the array.
[ ] specifies the rank of the array, i.e., the size of the array.
arrayName specifies the name of the array.
Example of an array declared in C#
C# Array Initialization:
Declaring an array does not initialize the array in the memory. You can assign values to the array only when the array variable is initialized. Array is a reference type, so you need to use the "new" keyword to create an instance of the array, that is to initialize the array.
double balance = new double;