I was looking for a screenshot of an old app I wrote, and I ran
across this code from 2001. This is the shortest .NET program I
Intermediate Language (IL) was new to us back then, so many of
us tried writing simple programs in it just to try it out. The
whole solution consists of three files: the resulting EXE, the
source IL and a batch file to do the compilation:
The code itself targets .NET 1.0 Beta 2. Here's the source .IL
file. There are more comments than code, but luckily that means it
should still be pretty easy to read.
// Hello World IL Program
// Written by Peter M. Brown
// August 15, 2001
// This is a minimal IL example. There are other options/attributes
// that can be used (and in many cases, should be used) but if it didn't
// prevent it from compiling, I bagged it :-)
// Requires Beta 2 version of ILASM and framework (1.0.2914)
// To assemble : ilasm HelloWorld.il
.assembly extern mscorlib
.class public ILHelloWorld
// This is our main function the .entrypoint attribute is
// what defines the "Mainness" of Main. If you leave this
// attribute off, you will get an IL assembler error
// Entry point must be a static function
.method public static void Main()
// print out a blank line
IL_0000: call void [mscorlib]System.Console::WriteLine()
// load our "Hello World" string
IL_0005: ldstr "Hello World! This is an IL program by Pete."
// print the string to the console using Console.Writeline
IL_0010: call void [mscorlib]System.Console::WriteLine(string)
// return from the function
IL_0015: ret // leave this out, and you'll get an exception
and here's the batch file. Again, more comments than code.
echo Make sure you are running version 1.0.2914 (beta 2 or later)
echo not 1.0.2204 of ilasm. This fails with beta 1.
You could write all your .NET apps this way if you really
wanted. IL is the assembler for .NET apps, the abstraction layer
between the languages and the runtime.