It would be appreciated if C# could be updated to 9.0 from 8.0. This would benefit code golfing exercises as C# 9.0 brings top-level statements. Code can be reduced from this:
using System;
class X
{
static void Main()
{
Console.WriteLine("Hello world!");
}
}
to this:
using System;
Console.WriteLine("Hello world!");
Currently with C# 8.0 this errors:
The feature ‘top-level statements’ is currently in Preview and unsupported. To use Preview features, use the ‘preview’ language version.csharp(CS8652)
Part of it is, but to get the full package you need to update from .Net core to .Net 5 too.
I’ve done it recently for my job, that was surprisingly easy
You can but it’s limited, quoting from someone else :
Using <LangVersion>9.0</LangVersion> with .Net Core 3.1 is possible, however there are three categories of features in C# :
features that are entirely part of the compiler, those will work.
features that require BCL additions. Since .Net Core is on an older BCL, those would need to be backported (for example to use init setters and records, you could import https://github.com/manuelroemer/IsExternalInit).
features that require runtime additions, those cannot be added and won’t work (for example default interface implementations in C# 8 and covariant return types in C# 9).