C#中的Type.GetArrayRank()方法
C#中的Type.GetArrayRank()方法获取数组中的维数。
语法
public virtual int GetArrayRank ();
现在让我们看一个实现Type.GetArrayRank()方法的示例-
示例
using System;
public class Demo {
public static void Main(string[] args) {
Type type = typeof(int[,, ]);
int arrRank = type.GetArrayRank();
Console.WriteLine("Array Rank = {0}", arrRank);
}
}输出结果
这将产生以下输出-
Array Rank = 3
现在让我们来看另一个实现Type.GetArrayRank()方法的示例-
示例
using System;
public class Demo {
public static void Main(string[] args) {
Type type = typeof(string[,,,,,,, ]);
Type type2 = typeof(string[,,,,,,, ]);
int arrRank = type.GetArrayRank();
Console.WriteLine("Array Rank = {0}", arrRank);
Console.WriteLine("Are both types equal? {0}", type.Equals(type2));
}
}输出结果
这将产生以下输出-
Array Rank = 8 Are both types equal? True
热门推荐
1 狗狗技巧训练
3 狗狗倒转训练
5 狗狗厕所怎么训练
6 狗狗训练做
8 狗狗喂养训练
10 声音训练狗狗
11 训练狗狗原理
12 几个月的狗狗开始训练
13 怎样训练狗狗在家里大小便
14 训练狗狗词语
15 简单训练狗狗
16 口语训练狗狗
17 英语听力训练狗狗
18 警犬训练狗狗