Commonly Used IL Instructions

Most likely, you will see instructions with ILDasm, but you might instead want to build your own IL code.

Note

The counterpart to ILDasm is ILasm. ILasm takes in IL code instructions and generates an assembly. It is possible to take the output of ILDasm and feed it into ILasm.

These instructions can be grouped into loading, storing, branching or flow control, operations, and object model. They are covered in detail in the following subsections.

IL Instructions for Loading

Following is a list of instructions that are used for loading values onto the evaluation stack.

  • ldc— This loads a numeric constant onto the stack. You will see this instruction whenever you have a hard-coded constant that you need to operate on ...

Get .NET Common Language Runtime Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.