C# TypeInfo GetArrayRank
Description
TypeInfo GetArrayRank
Gets the number of dimensions
in an Array.
Syntax
TypeInfo.GetArrayRank
has the following syntax.
public virtual int GetArrayRank()
Returns
TypeInfo.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.
// w ww . j a v a2 s .c o m
using System;
class MyArrayRankSample
{
public static void Main()
{
int[,,] myArray = new int[,,] {{{12,2,35},{3,78,1}},{{92,42,1},{30,7,3}}};
Type myType = myArray.GetType();
Console.WriteLine("Contents of myArray: {{{12,2,35},{1,78,1}},{{92,42,1},{30,7,3}}}");
Console.WriteLine("myArray has {0} dimensions.", myType.GetArrayRank());
}
}
The code above generates the following result.