OpCodes.Ldc_I4 字段


将所提供的 int32 类型的值作为 int32 推送到计算堆栈上。Pushes a supplied value of type int32 onto the evaluation stack as an int32.

public: static initonly System::Reflection::Emit::OpCode Ldc_I4;
public static readonly System.Reflection.Emit.OpCode Ldc_I4;
 staticval mutable Ldc_I4 : System.Reflection.Emit.OpCode
Public Shared ReadOnly Ldc_I4 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
20 < int32 >20 < int32 > ldc. i4 numldc.i4 num 将值 num 推送到堆栈上。Pushes the value num onto the stack.

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

  1. num 将被推送到堆栈上。The value num is pushed onto the stack.

请注意,对于从-128 到127的整数,会有特殊的简短编码(因而更有效),尤其是-1 到8的短编码。Note that there are special short (and hence more efficient) encodings for the integers -128 through 127, and especially short encodings for -1 through 8. 所有短编码将4字节整数推送到堆栈上。All short encodings push 4 byte integers on the stack. 较长的编码用于8字节整数、4字节和8字节浮点数,以及不符合短格式的4字节值。Longer encodings are used for 8 byte integers and 4 and 8 byte floating-point numbers, as well as 4-byte values that do not fit in the short forms. 有三种方法可将8字节整数常量推送到堆栈上There are three ways to push an 8 byte integer constant onto the stack

  1. 对于必须以32多位表示的常量,请使用 Ldc_I8 指令。Use the Ldc_I8 instruction for constants that must be expressed in more than 32 bits.

  2. 对于需要9到32位的常量,请使用 @no__t 后跟 Conv_I8 的指令。Use the Ldc_I4 instruction followed by a Conv_I8 for constants that require 9 to 32 bits.

  3. 对于可以用8个或更少位表示的常量,请使用短格式指令,后跟一个 Conv_I8Use a short form instruction followed by a Conv_I8 for constants that can be expressed in 8 or fewer bits.

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

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