static void Main(string[] args) { int[,] nums = new int[3, 5]; Console.WriteLine(nums.Length); Console.WriteLine(nums.LongLength); Console.WriteLine(nums.Rank); Console.WriteLine(nums.GetLength(0)); Console.WriteLine(nums.GetLength(1)); Console.WriteLine(nums.GetLongLength(0)); Console.WriteLine(nums.GetLongLength(1)); Console.WriteLine(nums.GetLowerBound(0)); Console.WriteLine(nums.GetLowerBound(1)); Console.WriteLine(nums.GetUpperBound(0)); Console.WriteLine(nums.GetUpperBound(1)); }
- 属性
- Length:获得32位整数,数组所有维度中元素的总数,上述代码输出:15
- LongLength:获得64位整数数组所有维度中元素的总数,上述代码输出:15
- Rank:获得数组的维度,上述代码输出:2 (二维数组)
- 方法
- GetLength:获得32位整数,数组指定维度中元素的总数,上述代码输出:GetLength(0) ->3 GetLength(1) -> 5
- GetLongLength:获得64位整数,数组指定维度中元素的总数,上述代码输出:GetLongLength(0) ->3 GetLongLength(1) -> 5
- GetLowerBound:获得数组指定维度的下限,上述代码输出:GetLowerBound(0) -> 0 GetLowerBound(1) ->0 (意思是数组下标从几开始)
- GetUpperBound:获得数组指定维度的上限,上述代码输出:GetUpperBound(0) -> 2 GetUpperBound(1) ->4 (意思是数组下标到几结束)
时间: 2024-11-13 08:08:17