How to switch to C# 13
How to fix 'Feature is not available in C# 12.0' and switch your project to C# 13 by changing the target framework or setting LangVersion in your .csproj file.
While trying out C# 13 features, it’s possible you might come across errors similar to these:
Feature is not available in C# 12.0. Please use language version 13.0 or later.
or
Error CS8652: The feature ‘
’ is currently in Preview and unsupported. To use Preview features, use the ‘preview’ language version.
There are two ways to solve this error:
- change the target framework of your project to .NET 9 or higher. The language version should be updated automatically.
- edit your .csproj file and specify the desired
like in the example below:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
</PropertyGroup>
</Project>
Language version is greyed out and cannot be modified
The Language version cannot be changed from the Properties window of the project. The version is linked to the target .NET framework version of your project and will be updated accordingly depending on that.
If you must override the language version, you have to do it as specified above, by modifying the .csproj file and specifying the LangVersion.
Remember that each C# language version has a minimum supported .NET version. C# 13 is supported only on .NET 9 and newer versions. C# 12 is supported only on .NET 8 and newer versions.
C# LangVersion options
Besides the version numbers, there are certain keywords that can be used to specify the language version of your project:
- preview – refers to the latest preview version
- latest – the latest released version (including minor version)
- latestMajor or default – the latest released major version
Not what you’re looking for?
You might be looking to switch to a different version of C#, in that case:
