Type.GetArrayRank Method ()
.NET Framework (current version)
Gets the number of dimensions in an array.
Assembly: mscorlib (in mscorlib.dll)
Return Value
Type: System.Int32An integer that contains the number of dimensions in the current type.
Implements
_Type.GetArrayRank()| 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.
Imports System Imports Microsoft.VisualBasic Class MyArrayRankSample Public Shared Sub Main() Try Dim myArray(,,) As Integer = {{{12, 2, 35}, {300, 78, 33}}, {{92, 42, 135}, {30, 7, 3}}} Dim myType As Type = myArray.GetType() Console.WriteLine("Contents of myArray: {{{12,2,35},{300,78,33}},{{92,42,135},{30,7,3}}}") Console.WriteLine("myArray has {0} dimensions.", myType.GetArrayRank()) Catch e As NotSupportedException Console.WriteLine("NotSupportedException raised.") Console.WriteLine(("Source: " + e.Source)) Console.WriteLine(("Message: " + e.Message)) Catch e As Exception Console.WriteLine("Exception raised.") Console.WriteLine(("Source: " + e.Source)) Console.WriteLine(("Message: " + e.Message)) End Try End Sub 'Main End Class 'MyArrayRankSample
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show: