Type.GetArrayRank() 方法(C# 中)
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
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP