OpCodes.Stelem 字段

定义

用计算堆栈中的值替换给定索引处的数组元素,其类型在指令中指定。Replaces the array element at a given index with the value on the evaluation stack, whose type is specified in the instruction.

public: static initonly System::Reflection::Emit::OpCode Stelem;
public static readonly System.Reflection.Emit.OpCode Stelem;
 staticval mutable Stelem : System.Reflection.Emit.OpCode
Public Shared ReadOnly Stelem 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
A4 < T >A4 < T > stelem typeTokstelem typeTok 将所提供索引处的数组元素替换为堆栈上的类型 typeTokReplaces the array element at the supplied index with a value of type typeTok on the stack.

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

  1. 对数组 array 的对象引用被推送到堆栈上。An object reference to an array, array, is pushed onto the stack.

  2. @No__t-1 中的元素的索引值 index 被推送到堆栈上。An index value, index, to an element in array is pushed onto the stack.

  3. 指令中指定的类型的值被推送到堆栈上。A value of the type specified in the instruction is pushed onto the stack.

  4. 从堆栈中弹出值、索引和数组引用;将值放入给定索引处的数组元素。The value, the index, and the array reference are popped from the stack; the value is put into the array element at the given index.

@No__t-0 指令用值替换一维 @no__t 数组中提供的从零开始的索引处的元素的值。The stelem instruction replaces the value of the element at the supplied zero-based index in the one-dimensional array array with the value. 值具有指令中的标记 typeTok 所指定的类型。The value has the type specified by the token typeTok in the instruction.

数组是对象,因此由类型 O 的值表示。Arrays are objects, and hence represented by a value of type O. 索引的类型为 native intThe index is type native int.

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

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

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

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

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

适用于