1.访问方式
(1)数字索引
int[] a = new int[10];
var item = a[5];
(2)^运算符
^0 =>array.Length
^n =>array.Length - n,即末尾第n个
int[] array = new int[10];
var item1 = array[^1];
//即array[array.Length - 1],末尾元素
var item2 = array[^array.Length];
//即array[0],首元素
注:数组切片:
array[1..5] //array[1]~array[4] array[..5] //array[0]~array[4] array[1..] //array[0]~array[array.Length - 1]