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.
using namespace System; int main() { try { array<Int32, 3>^myArray = gcnew array<Int32,3>(3,4,5); Type^ myType = myArray->GetType(); Console::WriteLine( "myArray has {0} dimensions.", myType->GetArrayRank() ); } catch ( NotSupportedException^ e ) { Console::WriteLine( "NotSupportedException raised." ); Console::WriteLine( "Source: {0}", e->Source ); Console::WriteLine( "Message: {0}", e->Message ); } catch ( Exception^ e ) { Console::WriteLine( "Exception raised." ); Console::WriteLine( "Source: {0}", e->Source ); Console::WriteLine( "Message: {0}", e->Message ); } }
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: