System.Array.Rank Property

Gets the rank (number of dimensions) of the Array. For example, a one-dimensional array returns 1, a two-dimensional array returns 2, and so on.

Syntax

[get: System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)]
public int Rank { get; }

Value

A int that contains the rank (number of dimensions) of the current instance.

Remarks

For example, the Visual Basic code

Example

Dim TDArray(0,0,0) As Integer

and the C# code

Example

int[,,] TDArray = new int[1,1,1];

create an array of three dimensions with a Array.Rank property whose value is 3.

A jagged array (an array of arrays) is a one-dimensional array; the value of its Array.Rank property is 1.

Retrieving the value of this property is an O(1) operation.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0