Skobo Do
Skobo Do

Reputation: 59

C# understanding intermediate language

I am new to c#. I am currently follow some tutorials and try to learn how to read the intermediate language (IL) with ildasm.exe.

I wrote this short code in c#:

using System;

namespace MainApp
{
    class App
    {
        public static void Main()
        {
            int[] array1D = new int[4];
            int len = array1D.GetLength(0);
            //Console.WriteLine(array1D[1]);
        }
    }
}

Then, I compiled the code and got this il-code:

.method public hidebysig static void  Main() cil managed
{
  .entrypoint
  // Code size       17 (0x11)
  .maxstack  2
  .locals init (int32[] V_0,
           int32 V_1)
  IL_0000:  nop
  IL_0001:  ldc.i4.4
  IL_0002:  newarr     [System.Runtime]System.Int32
  IL_0007:  stloc.0
  IL_0008:  ldloc.0
  IL_0009:  ldc.i4.0
  IL_000a:  callvirt   instance int32 [System.Runtime]System.Array::GetLength(int32)
  IL_000f:  stloc.1
  IL_0010:  ret
} // end of method App::Main

My question: What the point of line 7 and 8?

Upvotes: 0

Views: 322

Answers (0)

Related Questions