You can change the C# language version in Visual Studio in several ways.
Method 1: Project Properties (recommended)
- Open your project in Visual Studio.
- In Solution Explorer, right-click the project → Properties.
- Open the Build tab.
- Click Advanced… (bottom of the page).
- Find Language version.
- Select the desired version.
- default
- latest
- preview
- Or, specific versions like 13.0, 12.0, 11.0, etc.
- Save and rebuild.
Method 2: Edit .csproj directly (in SDK-style projects)
Right-click project → Edit Project File and add:
<PropertyGroup>
<LangVersion>13.0</LangVersion>
</PropertyGroup>
Examples:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>13.0</LangVersion>
</PropertyGroup>
</Project>
Save → rebuild.
Method 3: Change for all projects using Directory.Build.props
Create a file named: Directory.Build.props
Add:
<Project>
<PropertyGroup>
<LangVersion>13.0</LangVersion>
</PropertyGroup>
</Project>
This applies to all projects under that folder.
No comments:
Post a Comment