System.Array.GetValue Method

Gets the value at the specified position in the multidimensional Array. The indexes are specified as an array of 32-bit integers.

Syntax

public object GetValue (params int[] indices)

Parameters

indices
A one-dimensional array of 32-bit integers that represent the indexes specifying the position of the Array element to get.

Returns

The value at the specified position in the multidimensional Array.

Exceptions

TypeReason
ArgumentNullException indices is null.
ArgumentExceptionThe number of dimensions in the current instance is not equal to the number of elements in indices.
IndexOutOfRangeExceptionAt least one element in indices is outside the range of valid indices for the corresponding dimension of the current instance.

Remarks

The number of elements in indices must equal the number of dimensions in the Array. All elements in the indices array must collectively specify the position of the desired element in the multidimensional Array.

The Array.GetLowerBound(int) and Array.GetUpperBound(int) methods can determine whether any of the indexes is out of bounds.

This method 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