Type::GetArrayRank Method
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.
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 ); } }
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.