OpCodes.Ldelema 字段


将位于指定数组索引的数组元素的地址作为 & 类型(托管指针)加载到计算堆栈的顶部。Loads the address of the array element at a specified array index onto the top of the evaluation stack as type & (managed pointer).

public: static initonly System::Reflection::Emit::OpCode Ldelema;
public static readonly System.Reflection.Emit.OpCode Ldelema;
 staticval mutable Ldelema : System.Reflection.Emit.OpCode
Public Shared ReadOnly Ldelema As OpCode 



下表列出了指令的十六进制和 Microsoft 中间语言(MSIL)程序集格式以及简短的参考摘要:The following table lists the instruction's hexadecimal and Microsoft Intermediate Language (MSIL) assembly format, along with a brief reference summary:

格式Format 程序集格式Assembly Format 说明Description
8F < T >8F < T > ldelema classldelema class 将位于 index 的数组元素的地址作为类型 & (托管指针)加载到计算堆栈的顶部。Loads the address of the array element at index onto the top of the evaluation stack as type & (managed pointer).

堆栈转换行为顺序如下:The stack transitional behavior, in sequential order, is:

  1. array 的对象引用推送到堆栈上。An object reference array is pushed onto the stack.

  2. 索引值 index 将被推送到堆栈上。An index value index is pushed onto the stack.

  3. index 和 @no__t 从堆栈中弹出;查找 array 位置 index 位置中存储的地址。index and array are popped from the stack; the address stored at position index in array is looked up.

  4. 该地址将被推送到堆栈上。The address is pushed onto the stack.

@No__t-0 用于检索对象数组(类型 class)中特定索引处的对象的地址。The ldelema is used to retrieve the address of an object at a particular index in an array of objects (of type class). @No__t-0 指令将值的地址加载到从零开始的一维 @no__t 数组中的索引 index (类型 native int)处,并将其放在堆栈顶部。The ldelema instruction loads the address of the value at index index (type native int) in the zero-based one-dimensional array array and places it on the top of the stack. 数组是对象,因此由类型 O 的值表示。Arrays are objects and hence represented by a value of type O. 值的类型必须是与指令传递 classThe value must be of type class passed with the instruction.

@No__t 的返回值为托管指针(类型 @no__t 为-1)。The return value for ldelema is a managed pointer (type &).

请注意,在将小于4个字节的整数值加载到计算堆栈上时,将其扩展到 int32 (而不是 native int)。Note that integer values of less than 4 bytes are extended to int32 (not native int) when they are loaded onto the evaluation stack.

如果 array 为 null 引用,则会引发 NullReferenceExceptionNullReferenceException is thrown if array is a null reference.

如果 array 不包含所需类型的元素,则会引发 ArrayTypeMismatchExceptionArrayTypeMismatchException is thrown if array does not hold elements of the required type.

如果 index 为负数或大于 array 的界限,则会引发 IndexOutOfRangeExceptionIndexOutOfRangeException is thrown if index is negative, or larger than the bound of array.

以下 @no__t 0 方法重载可以使用 @no__t 操作码:The following Emit method overload can use the ldelema opcode:

  • ILGenerator (OpCode,Type)ILGenerator.Emit(OpCode, Type)