The IL code can be grouped as follows:
IL_0000: nop IL_0001: ldarg.0 // get the value for the parameter IL_0002: ldarg.0 IL_0003: ldfld int32 ConsoleApplication1.SimpleIL::f IL_0008: box [mscorlib]System.Int32 // call "this.M2(...)", this is already on the stack from before IL_000d: call instance void ConsoleApplication1.SimpleIL::M2(object) IL_0012: nop IL_0013: ret
To invoke a method using IL, you do the following:
load instance reference on the stack load argument values on the stack call method
Here, the “instance reference” was first loaded onto the stack, then code was added to get the value of the parameter, which also included getting the reference to the instance on the stack, followed by the actual call that uses the instance reference.
source share