(a)
using System;
public class Hello {
  public static void Main() {
    int a = 23 + 67;
    Console.WriteLine(++a);
  }
}

(b)
bjepson@VMWARE /cygdrive/o/mono/mono-test
$ compiler Hello.cs
Parsing successful

bjepson@VMWARE /cygdrive/o/mono/mono-test
$ ls -l Hello.exe
-rwxr-xr-x    1 bjepson  None         2048 Oct  4 21:54 Hello.exe

bjepson@VMWARE /cygdrive/o/mono/mono-test
$ file Hello.exe
Hello.exe: MS Windows PE 32-bit Intel 80386 console executable

(c)
.MEthod public static
       default void Main()  cil managed
{
    // Method begins at RVA 0x2064
    .entrypoint
    // Code size 17 (0x11)
    .maxstack 2
    .locals (
            int32   V_0)
    IL_0000: ldc.i4.s 0x17
    IL_0002: ldc.i4.s 0x43
    IL_0004: add
    IL_0005: stloc.0
    IL_0006: ldloc.0
    IL_0007: ldc.i4.1
    IL_0008: add
    IL_0009: dup
    IL_000a: stloc.0
    IL_000b: call void System.Console::WriteLine(int32)
    IL_0010: ret
}

(d)
bjepson@VMWARE /cygdrive/o/mono/mono-test
$ mint Hello.exe
91

Example 2: From C# to the Common Intermediate Language (CIL).

Back to Article