Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Type.GetArrayRank() Method in C#
The Type.GetArrayRank() method in C# gets the number of dimensions in an array.
Syntax
public virtual int GetArrayRank ();
Let us now see an example to implement the Type.GetArrayRank() method −
Example
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);
}
}
Output
This will produce the following output −
Array Rank = 3
Let us now see another example to implement the Type.GetArrayRank() method −
Example
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));
}
}
Output
This will produce the following output −
Array Rank = 8 Are both types equal? True
Advertisements