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