GetLength获取一个32位整数,该整数表示Array指定维中的元素数。
首先,设置数组。
int[,] arr = new int[20, 30];
对于数组的指定维,请在GetLength()方法中设置索引,例如-
Arr.GetLength(1);
using System;
class Program {
   static void Main() {
      int[,] arr = new int[20, 30];
      int len = arr.GetLength(1);
      Console.WriteLine(len);
   }
}输出结果
30