OpCodes.Conv_Ovf_I4_Un 字段


将位于计算堆栈顶部的无符号值转换为有符号 int32,并在溢出时引发 OverflowExceptionConverts the unsigned value on top of the evaluation stack to signed int32, throwing OverflowException on overflow.

public: static initonly System::Reflection::Emit::OpCode Conv_Ovf_I4_Un;
public static readonly System.Reflection.Emit.OpCode Conv_Ovf_I4_Un;
 staticval mutable Conv_Ovf_I4_Un : System.Reflection.Emit.OpCode
Public Shared ReadOnly Conv_Ovf_I4_Un 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
8484 conv.ovf.i4.unconv.ovf.i4.un 将无符号值转换为 int32 (在堆栈上为 int32)并在溢出时引发异常。Converts an unsigned value to an int32 (on the stack as int32) and throw an exception on overflow.

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

  1. value 推送到堆栈上。value is pushed onto the stack.

  2. 从堆栈中弹出 value,并尝试执行转换操作。value is popped from the stack and the conversion operation is attempted. 如果发生溢出,则会引发异常。If overflow occurs, an exception is thrown.

  3. 如果转换成功,则将结果值推送到堆栈上。If the conversion is successful, the resulting value is pushed onto the stack.

conv.ovf.i4.un opcode 将堆栈顶部的 value 转换为操作码中指定的类型,并将转换后的值放在堆栈的顶部。The conv.ovf.i4.un opcode converts the value on top of the stack to the type specified in the opcode, and places that converted value on the top of the stack. 如果值太大或太小而无法由目标类型表示,则会引发异常。If the value is too large or too small to be represented by the target type, an exception is thrown.

从浮点数到整数值的转换会将数字截断到零。Conversions from floating-point numbers to integer values truncate the number toward zero. 请注意,小于4个字节的整数值将在加载到计算堆栈时被扩展到 int32 (除非使用 conv.ovf.iconv.ovf.u,在这种情况下,结果也是 native int的)。Note that integer values of less than 4 bytes are extended to int32 when they are loaded onto the evaluation stack (unless conv.ovf.i or conv.ovf.u are used, in which case the result is also native int).

如果结果类型中不能表示结果,则会引发 OverflowExceptionOverflowException is thrown if the result can not be represented in the result type.

以下 Emit 方法重载可以使用 conv.ovf.i4.un 操作码:The following Emit method overload can use the conv.ovf.i4.un opcode:

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