I'm studying the new features about C# 11 and i don`t know if i can use it with .NET 6.0 or only in .NET 7.0.
I also saw that i can lock the version of C# like this:
<PropertyGroup>
<LangVersion>11</LangVersion>
</PropertyGroup>
Is there a good practice locking the version? Thinking that if there's a new feature in the language it can brake my application. Or just let it with latest is good enough?
CodePudding user response:
The official blog - Early peek at C# 11 features - states:
Visual Studio 17.1 (Visual Studio 2022 Update 1) and .NET SDK 6.0.200 include preview features for C# 11! You can update Visual Studio or download the latest .NET SDK to get these features.
(...)
Your .csproj file might look like:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net6.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> <LangVersion>preview</LangVersion> </PropertyGroup> </Project>
Using the latest version of the language and its preview features for studying is completely fine! (For production code it's nuanced.)