#6 – An Even Smaller C# Program
June 23, 2010 2 Comments
In The Smallest Possible C# Program, I mentioned a couple things as optional. For the record, here’s the absolute smallest C#.NET program that you can write. (Assuming that you don’t need it to actually do anything).
class Program
{
static void Main()
{
}
}
you could shorten the class name and get rid of whitespace for a even “shorter” program
That’s technically true, that you could remove whitespace and shorten the class name. But choosing meaningful names and properly formatting your code is important for purposes of maintainability. Also, the resulting program would not be any shorter, in terms of the number of elements and the resulting IL. The point of this post was to look at the core elements of a C# program, from a semantic point of view, rather to use the smallest number of characters for some reason.