Instantiating with Dynamic Methods
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.
Previous Module
Pointers in C#
This Module
Advanced Performance Optimizations