Type.GetArrayRank Method
Silverlight
Gets the number of dimensions in an Array.
Namespace: System
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 Use a Demo Method and a TextBlock Control. |
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. */
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Note: