Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use C#10 in Visual Studio 2019

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.

like image 927
jahav Avatar asked Dec 31 '25 06:12

jahav


1 Answers

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.

like image 77
mason Avatar answered Jan 03 '26 03:01

mason



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!