简体   繁体   中英

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

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM