ILGenerator:如何将布尔值添加到堆栈 [英] ILGenerator: How to add boolean to the stack
本文介绍了ILGenerator:如何将布尔值添加到堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我可以将浮点值放到栈中的方法(在C#中):
Here is the way I can put float value to the stack(in C#):
ILGenerator gen = method.GetILGenerator();
gen.Emit(OpCodes.Ldc_R4, (float)12.5);
如何使用Emit方法将布尔值放入堆栈?
How can I put boolean value to the stack by using Emit method?
推荐答案
在评估堆栈上没有布尔值的表示形式. bool,char,byte,ushort,uint及其带符号的变体均表示为4字节的带符号整数(i4).
There is no representation of a boolean value on the evaluation stack. The bool, char, byte, ushort, uint, and their signed variants are all represented as a 4-byte signed integer (i4).
是:
ldc.i4.1
错误:
ldc.i4.0
这篇关于ILGenerator:如何将布尔值添加到堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文