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