Format | Assembly Format | Description |
---|---|---|
8F <T> | ldelema typeTok |
Load the address of element at index onto the top of the stack. |
…, array, index → …, address
The ldelema
instruction loads the address of the element with index index (of type int32
or native int
) in the zero-based one-dimensional array array (of element type verifier-assignable-to typeTok) and places it on the top of the stack. Arrays are objects and hence represented by a value of type O
. The return address is a managed pointer (type &
).
[Note: For one-dimensional arrays that aren't zero-based and for multidimensional arrays, the array class provides an Address
method. end note]
If this instruction is prefixed by the readonly.
prefix, it produces a controlled-mutability managed pointer (§III.1.8.1.2.2).
System.NullReferenceException
is thrown if array is null.
System.IndexOutOfRangeException
is thrown if index is negative, or larger than the bound of array.
System.ArrayTypeMismatchException
is thrown if array doesn't hold elements of the required type.
Correct CIL ensures that class is a typeref
or typedef
or typespec
token to a class, and that array is indeed always either null or a zero-based, one-dimensional array whose declared element type is verifier-assignable-to typeTok.
Verification requires that:
-
the tracked type of array is
T[]
, for someT
, or theNull
type (§III.1.8.1.2); -
a managed pointer to
T
is pointer-element-compatible-with (§I.8.7.1) a managed pointer to typeTok; and -
the type of index is
int32
ornative int
.
Verification tracks the type of the result address as a managed pointer to the verification type of typeTok.