mathiasbynens / small

Smallest possible syntactically valid files of different types
https://mathiasbynens.be/notes/minimal-html
1.93k stars 184 forks source link

Make the csharp even smaller with the C# 9 changes #112

Open ctyar opened 4 years ago

ctyar commented 4 years ago

With top-level programs in C# 9, we can reduce the size significantly. The result is still same as:

class A
{
    static void Main()
    {
    }
}
dscorbett commented 4 years ago

I think it would be nice to keep the old file as csharp-8.cs, like how there are many files for old versions of HTML.

ctyar commented 4 years ago

@dscorbett done. Also, there is a new line at the end of the old file, should I remove that too?

dscorbett commented 4 years ago

Yes, assuming that a final newline wasn’t necessary in C# 8.

ToastyMallows commented 3 years ago

If we're just focusing on the .cs file itself and not the associated .csproj file, using top-level statements, here's the smallest file that I could come up with:

int a;

This file builds and runs, outputs nothing, and is 6 bytes in size.