I think I might be missing something important, but I can’t seem to figure out how to construct a conditional statement in IL with dynamic method. I’ve only dabbled lightly in it before, but I need to extend some code now.
Is there some documentation somewhere that I haven’t found (apart from the CLI documentation), or does someone have some sample code? That would be fantastic.
Cheers,
Depending on your exact code, the various branch instructions are your friend.
Here is
in IL:
You basically push the values you want to compare onto the stack and then call bgt to jump where you need to.
You can check the OpCodes Class for a quick overview of IL Commands, for example brtrue/brfalse or beq.
I would also recommend writing the if command in C#, compiling it, and using ILDASM or Reflector to look at the generated IL.