OpCodes.Stloc_S 字段


从计算堆栈的顶部弹出当前值并将其存储在局部变量列表中的 index 处(短格式)。Pops the current value from the top of the evaluation stack and stores it in a the local variable list at index (short form).

public: static initonly System::Reflection::Emit::OpCode Stloc_S;
public static readonly System.Reflection.Emit.OpCode Stloc_S;
 staticval mutable Stloc_S : System.Reflection.Emit.OpCode
Public Shared ReadOnly Stloc_S 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
13 < unsigned int8 >13 < unsigned int8 > stloc indexstloc.s index 从堆栈中弹出一个值,并将其存储在本地变量 index,缩写形式。Pops a value from the stack and stores it in local variable index, short form.

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

  1. 将从堆栈中弹出一个值并将其放入本地变量 indexA value is popped off of the stack and placed in local variable index.

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

@No__t-0 指令为局部变量0到255提供有效编码。The stloc.s instruction provides an efficient encoding for local variables 0 through 255.

如果存储在保持小于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.

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

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

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