Type.GetArrayRank Method
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets the number of dimensions in an Array.
Assembly: mscorlib (in mscorlib.dll)
| Exception | Condition |
|---|---|
| NotSupportedException | The functionality of this method is unsupported in the base class and must be implemented in a derived class instead. |
| ArgumentException | The current Type is not an array. |
The following example displays the number of dimensions in an array.
Note: |
|---|
To run this example, see Building examples that have static TextBlock controls for Windows Phone 8. |
using System; class Example { public static void Demo(System.Windows.Controls.TextBlock outputBlock) { int[,,] myArray = { { { 12, 2, 35 }, { 300, 78, 33 } }, { { 92, 42, 135 }, { 30, 7, 3 } } }; Type myType = myArray.GetType(); outputBlock.Text += String.Format("myArray has {0} dimensions.\n", myType.GetArrayRank()); } } /* This example produces the following output: myArray has 3 dimensions. */
Note: