Skip to main content
This is lesson 4 of 11 in this module Course 94% complete

Instantiating with Dynamic Methods

Premium Content

Sign in with your account or sign up to access this lesson.

The lesson shows how to use the ILGenerator class to emit a newobj IL opcode followed by a ret opcode into a blank DynamicMethod, then wrap a delegate around it for fast repeated invocation. We explain ConstructorInfo, the DynamicMethod constructor arguments, and how this technique lets the app act as a mini-compiler that generates and executes IL at runtime.