OpCodes.Stloc_2 字段

定义

从计算堆栈的顶部弹出当前值并将其存储到索引 2 处的局部变量列表中。Pops the current value from the top of the evaluation stack and stores it in a the local variable list at index 2.

public: static initonly System::Reflection::Emit::OpCode Stloc_2;
public static readonly System.Reflection.Emit.OpCode Stloc_2;
 staticval mutable Stloc_2 : System.Reflection.Emit.OpCode
Public Shared ReadOnly Stloc_2 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
0C0C stloc.2stloc.2 将值从堆栈中弹出到局部变量2中Pops a value from the stack into local variable 2

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

  1. 从堆栈中弹出一个值,并将其放入索引为2的局部变量中。A value is popped off of the stack and placed in the local variable indexed by 2.

@No__t-0 指令从计算堆栈中弹出顶部值,并将其移动到索引为2的局部变量中。The stloc.2 instruction pops the top value off the evaluation stack and moves it into the local variable indexed by 2. 值的类型必须与当前方法本地签名中指定的局部变量的类型匹配。The type of the value must match the type of the local variable as specified in the current method's local signature.

stloc.2 是在局部变量2中存储值的特别高效的编码。stloc.2 is an especially efficient encoding for storing values in local variable 2.

如果存储在保持小于4个字节的整数值的局部变量中,长时间将在从堆栈移到局部变量时截断值。Storing into locals that hold an integer value smaller than 4 bytes long truncates the value as it moves from the stack to the local variable. 浮点值从其本机大小(类型 F)舍入到与参数相关联的大小。Floating-point values are rounded from their native size (type F) to the size associated with the argument.

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

  • ILGenerator.Emit(OpCode)ILGenerator.Emit(OpCode)

适用于