Home > Article > Backend Development > What is a static array or fixed length array in C#?
Static array is a data structure with a fixed size. Let’s look at an example of a static array in C#.
This is a static string array. The data remains unchanged here i.e. fixed -
static string[] _fruits = new string[] { "apple", "mango" };
Now let us see the complete example of creating and accessing static array in C# -
using System; class Demo { static void Main() { foreach (string fruits in Program.Fruits) { Console.WriteLine(fruits); } } } public static class Program { static string[] _fruits = new string[] { "apple", "mango" }; public static string[] Fruits { get { return _fruits; } } }
The above is the detailed content of What is a static array or fixed length array in C#?. For more information, please follow other related articles on the PHP Chinese website!