c# - CIL OpCode (Ldarg_0) is used even though there are no arguments -


i have following c# code.

public void helloworld() {     add(2, 2); }  public void add(int a, int b) {     //do } 

it produces following cil

.method public hidebysig instance void  helloworld() cil managed {   // code size       11 (0xb)   .maxstack  8   il_0000:  nop   il_0001:  ldarg.0   il_0002:  ldc.i4.2   il_0003:  ldc.i4.2   il_0004:  call       instance void consoleapplication3.program::add(int32,                                                                       int32)   il_0009:  nop   il_000a:  ret } // end of method program::helloworld 

now, don't understand line @ offset 0001:

ldarg.0

i know opcode for, don't understand why it's being used in method, there no arguments, right?

does know why? :)

in instance methods there implicit argument index 0, representing instance on method invoked. can loaded on il evaluation stack using ldarg.0 opcode.


Comments

Popular posts from this blog

Eclipse formatter for java ending braces -

ruby - Nesting modules inside of a Rails eninge gem -

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -