Mono Class Library: System.Array Overview | Members

System.Array.SetValue Method

Sets the value of the element at the specified position in the current one-dimensional instance. [Edit]

public void SetValue (object value, int index)

Parameters

value
A object that contains the new value for the specified element. [Edit]
index
A int that contains the index of the element whose value is to be set. [Edit]

Exceptions

TypeReason
ArgumentExceptionThe current instance has more than one dimension. [Edit]
IndexOutOfRangeExceptionindex is outside the range of valid indices for the current instance. [Edit]
InvalidCastExceptionvalue is not assignment-compatible with the element type of the current instance. [Edit]

Remarks

Note:

Use the Array.GetLowerBound(int) and Array.GetUpperBound(int) methods to determine whether index is out of bounds.

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

[Edit]

Requirements

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