C# | Type.GetArrayRank() Method Last Updated : 11 Aug, 2021 Comments Improve Suggest changes Like Article Like Report Type.GetArrayRank() Method is used to get the number of dimensions in an array. Syntax: public virtual int GetArrayRank ();Return Value: This method returns an integer which contains the number of dimensions in the current type.Exception: This method throws ArgumentException if the current type is not an array. Below programs illustrate the use of Type.GetArrayRank() Method:Example 1: csharp // C# program to demonstrate the // Type.GetArrayRank() Method using System; using System.Globalization; using System.Reflection; class GFG { // Main Method public static void Main() { try { // Declaring and initializing Type object Type type = typeof(int[,,,,, ]); // Getting the dimensions // using GetArrayRank() int rank = type.GetArrayRank(); // Display the rank Console.WriteLine("ArrayRank is: {0}", rank); } catch (ArgumentException e) { Console.WriteLine("The current type is not an Array"); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: ArrayRank is: 6 Example 2: csharp // C# program to demonstrate the // Type.GetArrayRank() Method using System; using System.Globalization; using System.Reflection; class GFG { // Main Method public static void Main() { try { // Declaring and initializing Type object Type type = typeof(int); // Getting ArrayRank by // using GetArrayRank() int rank = type.GetArrayRank(); // Display the rank Console.WriteLine("ArrayRank is : {0}", rank); } catch (ArgumentException e) { Console.WriteLine("The current type is not an Array"); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: The current type is not an Array Exception Thrown: System.ArgumentException Reference: https://docs.microsoft.com/en-us/dotnet/api/system.type.getarrayrank?view=netcore-3.0 Comment More infoAdvertise with us Next Article C# | Type.GetArrayRank() Method R rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp-Type-Class Similar Reads C# | Type.GetTypeArray() Method Type.GetTypeArray() Method is used to get the types of the objects in the specified array. Syntax: public static Type[] GetTypeArray (object[] args); Here, it takes an array of objects whose types to determine. Return Value: This method returns an array of Type objects representing the types of the 2 min read C# | StringComparer.Compare Method In C#, the Compare method is used to compare two objects or strings and returns an indication of their relative sort order.Example: C# program to illustrate how to use StringComparer() to perform ordinal comparison.C#// C# program to illustrate the // CompareOrdinal(String, Int32, // String, Int32, 3 min read C# | Char.CompareTo() Method In C#, Char.CompareTo() is a System.Char struct method which is used to compare this instance of a specified object or value type and check whether the given instance is precedes, follow, or appears in the same position in the sort order as the specified object or value type. This method can be over 3 min read C# | Array.FindLast() Method This method is used to search for an element that matches the conditions defined by the specified predicate and returns the last occurrence within the entire Array. Syntax: public static T FindLast<T> (T[] array, Predicate<T> match); Parameters: array: It is the one-dimensional, zero-bas 3 min read C# | Array.LastIndexOf<T>(T[], T) Method Array.LastIndexOf<T>(T[], T) Method is used to search for the specified object. It returns the index of the last occurrence within the entire Array. Syntax: public static int LastIndexOf<T>(T[] array, T value); Parameters: array: It is a one-dimensional, zero-indexed array to search. val 2 min read Like