Format | Assembly Format | Description |
---|---|---|
A4 <T> | stelem typeTok |
Replace array element at index with the value on the stack |
…, array, index, value, → …
The stelem
instruction replaces the value of the element with zero-based index index (of type native int
or int32
) in the one-dimensional array array, with value. Arrays are objects and hence are represented by a value of type O
. The type of value must be array-element-compatible-with typeTok in the instruction.
Storing into arrays that hold values smaller than 4 bytes whose intermediate type is int32
truncates the value as it moves from the stack to the array. Floating-point values are rounded from their native size (type F
) to the size associated with the array. (See §III.1.1.1, Numeric data types.)
[Note: For one-dimensional arrays that aren't zero-based and for multidimensional arrays, the array class provides a StoreElement
method. end note]
System.NullReferenceException
is thrown if array is null.
System.IndexOutOfRangeException
is thrown if index is larger than the bound of array.
System.ArrayTypeMismatchException
is thrown if array doesn't hold elements of the required type.
typeTok shall be a valid typedef
, typeref
, or typespec
metadata token.
array shall be null or a single dimensional array.
Verification requires that:
-
the tracked type of array is
T[]
, for someT
; -
the tracked type of value is array-element-compatible-with (§I.8.7.1) typeTok;
-
typeTok is array-element-compatible-with
T
; and -
the type of index is
int32
ornative int
.