Question

using c#, ,Net framework 4.5 notePad

Try understand principles of CIL (IL) language. Currently create 2 simple method

 public static Int32 Add(Int32 a, Int32 b)
    {
        return a + b;
    }
    public Int32 Add1(Int32 a, Int32 b)
    {
        return a + b;
    }

After opening in ildasm.exe got

ildasm result

Question

Why in Add method CIL make loading argument in stack 0 and in second in stack 1 - Where used stack 0 in method Add1 Or i something missed?

Was it helpful?

Solution

Your first method gets passed two arguments, a (0) and b (1). Your second gets passed three arguments, this (0), a (1), and b (2). Even though you're not using this, it's still there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top