配列のサイズを調べる方法
Lengthを使って配列のサイズを調べることができます。
int[] array1 = new int[]{ 1, 2, 3, 4, 5 };
Debug.Log($"Length = {array1.Length}");実行結果
Length = 5ジャグ配列の場合
int[][] array2 = new int[][]{
  new int[] { 1, 2, 3 },
  new int[] { 4, 5, 6, 7 }
};
Debug.Log($"Length = {array2.Length}");
Debug.Log($"Length = {array2[0].Length}");
Debug.Log($"Length = {array2[1].Length}");実行結果
Length = 2
Length = 3
Length = 4多次元配列の場合
多次元配列の場合はGetLengthを使って調べられます。
int[,] array3 = new int[,]{
  { 1, 2, 3 },
  { 4, 5, 6 }
};
Debug.Log($"Length = {array3.GetLength(0)}");
Debug.Log($"Length = {array3.GetLength(1)}");実行結果
Length = 2
Length = 3