Dear MVPs:
I have an interesting question for you...well, I find it interesting at
least. I am giving a talk on .NET technologies next Friday and while I was
working on creating a few examples I noticed something in my work that I had
not noticed before.
When I compile a simple C# hello world application as follows, I get a 3,072
byte executeable
public class HelloWorld {
public static void Main( ) {
System.Console.WriteLine("Hello World!");
}
}
....but when I "ildasm /out=helloworld_cs_il.li" that and then "ilasm
helloworld_cs_il.il" THAT I get a 2,048 byte file.
Even when I do this with VB, my exe goes from 6,144 bytes to 5,140 bytes.
Of course a direct IL implementation of a simple Hello World example (which
wouldn't require a class at all; well, it's identical to your Hello World
example), renders something as 2,048 bytes, which is the same size as what
the C# version went to after a visit from ildasm and ilasm. Since it's 2^11,
I can only assume that's some sort of minimum because I would think that the
IL version would be smaller than the CS->EXE->IL->EXE version.
So,
Question 1: Why in the world would my C# code which went to EXE(3,072) back
to IL and then to EXE again get SMALLER when I disassembled and reassembled?
Or why the VB version shrunk?
Question 2: Is my theory about 2,048 bytes as a minimum even close?
Question 3: It's not a big deal, but do you think it's a coincidence that
the VB version is EXACTLY twice the size of the original C# version?