Home > Mobile >  What is the relationship between C# 10 and .NET Core 6
What is the relationship between C# 10 and .NET Core 6

Time:08-10

Is there a link between .NET versions and do they pack the language versions in them? Googling is not delivering any clear answers. Looks like everyone except me knows this stuff.

Any reading links will be welcome.

CodePudding user response:

You can lookup the details at Microsoft, for a pure language perspective look here: https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history

The compatibility is listed here:

C# 11 is supported only on .NET 7 and newer versions. C# 10 is supported only on .NET 6 and newer versions. C# 9 is supported only on .NET 5 and newer versions. C# 8.0 is supported only on .NET Core 3.x and newer versions.

CodePudding user response:

See C# language versioning table.

Note that this only minimum supported language version. Many language features work fine in older, non-supported .Net versions, but require the csproj file to be edited manually to add <LangVersion>latest</LangVersion> to specify that you want to use the latest supported c# version.

So my approach is basically:

  1. Use the newest .Net version you can
  2. If you cannot use the latest .Net version, add the LangVersion switch to get the latest c# version. This is not technically supported, so might cause issues, but I have yet to encounter any significant problems.
  • Related