C# Type GetArrayRank
Description
Type GetArrayRank
gets the number of dimensions in an
Array.
Syntax
Type.GetArrayRank
has the following syntax.
public virtual int GetArrayRank()
Returns
Type.GetArrayRank
method returns An Int32 containing the number of dimensions in the current Type.
Example
The following example displays the number of dimensions in an array.
//from www.ja v a 2 s . c o m
using System;
class MyArrayRankSample
{
public static void Main()
{
int[,,] myArray = new int[,,] {{{12,2,3},{3,7,3}},{{9,2,1},{3,7,3}}};
Type myType = myArray.GetType();
Console.WriteLine("myArray has {0} dimensions.", myType.GetArrayRank());
}
}
The code above generates the following result.