C#中的GetLongLength方法获取一个64位整数,该整数表示Array指定维中的元素数。
首先,设置数组。
long[,] arr2= new long[15, 35];
对于数组的指定维,请在GetLongMethod()方法中设置索引,例如-
long len2 = arr2.GetLongLength(0);
让我们看完整的例子。
using System;
class Program {
   static void Main() {
      int[,] arr = new int[20, 30];
      int len = arr.GetLength(0);
      Console.WriteLine(len);
      long[,] arr2= new long[15, 35];
      long len2 = arr2.GetLongLength(0);
      Console.WriteLine(len2);
   }
}输出结果
20 15