Home > database >  How to use C#10 in Visual Studio 2019
How to use C#10 in Visual Studio 2019

Time:11-17

How can I use C# 10 in Visual Studio 2019? I have latest update (16.11.6) and when I try to make a new project (need NET Standard 2.0, for compatibility with 4.7.2) and change it to C#10

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <LangVersion>10.0</LangVersion>
  </PropertyGroup>
</Project>

The IDE will show C#10 features a warning (this is for global usings):

"CS8652: The feature 'global using directive' is currently in Preview and unsupported. To use Preview features, use the 'preview' language version."

When I change the LangVersion to preview, it at least compiles, but my team has a mix of VS2022 and VS 2019 (to be upgraded later), so I am looking for a way to use proper langversion version (I am not comfortable to use preview) that works for all of them.

CodePudding user response:

According to the documentation C# 10 is only supported on .NET 6.

C# 10 is supported only on .NET 6 and newer versions.

According to the .NET 6 announcement, .NET 6 is only supported in Visual Studio 2022. Not in Visual Studio 2019.

.NET 6 is supported with Visual Studio 2022 and Visual Studio 2022 for Mac. It is not supported with Visual Studio 2019, Visual Studio for Mac 8, or MSBuild 16. If you want to use .NET 6, you will need to upgrade to Visual Studio 2022. .NET 6 is supported with the Visual Studio Code C# extension.

  • Related