C#-এ Type.GetArrayRank() মেথডটি একটি অ্যারের ডাইমেনশন (dimension) বা র্যাঙ্কের সংখ্যা পেতে ব্যবহৃত হয়।
সিনট্যাক্স
public virtual int 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
আরেকটি উদাহরণ: ৮-ডাইমেনশনাল অ্যারে
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