Which version of C# am I using in Visual Studio 2019

If you’re using the latest version of Visual Studio 2019, C#, you may not see the option to change the C# language version of your project. This is a new change in Visual Studio 2019/.NET Core 3.0. The new C# compiler chooses the default version based on your .NET target framework selected for your project in Visual Studio.


The compiler determines a default language based on the following rules: 

Target framework version C# language version default

.NET Core             3.x   C# 8.0
.NET Core             2.x   C# 7.3
.NET Framework   all   C# 7.3

Note: If you’re using a previous version of Visual Studio, you’ve an option to select a language version up to C# 7.3.

C# 8.0 is the latest version of C# language. C# 8.0 introduces several new features. To learn more about these features, visit https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8

Can I change the default C# version?

Yes, you may.

If you open your .csproj project file in Notepad or any text editor, you can add a new property group and set the LangVersion value to specify the language version your project will use. The default proj file looks like the following in XML.

<Project Sdk="Microsoft.NET.Sdk">  
<PropertyGroup>  
<OutputType>Exe</OutputType>  
<TargetFramework>netcoreapp3.0</TargetFramework>  
</PropertyGroup>  
</Project>  
The  
<Project Sdk="Microsoft.NET.Sdk">  
<PropertyGroup>  
<OutputType>Exe</OutputType>  
<TargetFramework>netcoreapp3.0</TargetFramework>  
</PropertyGroup>  
<PropertyGroup>  
<LangVersion>8.0</LangVersion>  
</PropertyGroup>  
</Project>  

The LangVersion value can be one of the following: 

preview
latest
latestMajor
8.0
7.3
7.2
7.1
7, 6, 5, 4, and 3


Recommended Free Ebook
Similar Articles
Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.