Search code examples
c#.netcil

In the IL code produced, there are some lines missing. What task does the in between lines perform?


.method private hidebysig static void  Main(string[] args) cil managed
{
  .entrypoint
  // Code size       9 (0x9)
  .maxstack  1
  .locals init ([0] class ConstReadOnly.second p)
  IL_0000:  nop
  IL_0001:  ldc.i4.5
  IL_0002:  newobj     instance void ConstReadOnly.second::.ctor(int32)
  IL_0007:  stloc.0
  IL_0008:  ret
} // end of method Program::Main

Here the IL_0002 is followed by IL_0007.
Can any one please give me the actual scenario happening here?


Solution

  • It's only labels. There's no code in between. The label represents offset from the beginning off the function in bytes.

    offset_0:  nop      //size 1 byte
    offset_1:  ldc.i4.5 // size 1 byte
    offset_2:  newobj instance void ConstReadOnly.second::.ctor(int32) // size 5 bytes
    offset_7:  stloc.0 // size 1 byte 
    offset_8:  ret
    

    You can easily change them and recompile again.