Array (C#)
An array in C# is a fixed-size collection of items that all share the same type, stored in order and accessed by a zero-based index. Its length can't change once it's created.
C#
You declare an array's type with square brackets, like int[] or string[]. The first element is at index 0, and you read the number of elements with the .Length property.
When you need a collection that can grow or shrink, use a List<T> instead of a plain array.
Syntax
type[] name = new type[size];Examples
C#
string[] fruits = { "apple", "banana", "cherry" };
Console.WriteLine(fruits[0]);
Console.WriteLine(fruits.Length);Output:
apple
3