Mảng tĩnh là cấu trúc dữ liệu kích thước cố định. Ví dụ mảng string tĩnh:
static string[] _fruits = new string[] { "apple", "mango" };
Dữ liệu không thay đổi (cố định).
Ví dụ hoàn chỉnh
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; }
}
}