Mono Class Library: System.Array Overview | Members

System.Array.SetValue Method

Sets the value of the element at the specified position in the current multidimensional instance. [Edit]

public void SetValue (object value, params int[] indices)

Parameters

value
A object that contains the new value for the specified element. [Edit]
indices
A one-dimensional array of int objects that contains the indices that specify the position of the element in the current instance to set. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionindices is null. [Edit]
ArgumentExceptionThe number of dimensions in the current instance is not equal to the number of elements in indices. [Edit]
IndexOutOfRangeExceptionAt least one element in indices is outside the range of valid indices for the corresponding dimension of the current instance. [Edit]
InvalidCastExceptionvalue is not assignment-compatible with the element type of the current instance. [Edit]

Remarks

The number of elements in indices is required to be equal to the number of dimensions in the current instance. All elements in indices collectively specify the position of the desired element in the current instance.

Note:

For more information regarding valid conversions that will be performed by this method, see Convert.

Use the Array.GetLowerBound(int) and Array.GetUpperBound(int) methods to determine whether any of the values in indices is out of bounds.

[Edit]

Requirements

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