Friday, June 26, 2026

How to change C# version in Visual Studio

You can change the C# language version in Visual Studio in several ways.
Method 1: Project Properties (recommended)

  1. Open your project in Visual Studio.
  2. In Solution Explorer, right-click the project → Properties.
  3. Open the Build tab.
  4. Click Advanced… (bottom of the page).
  5. Find Language version.
  6. Select the desired version.
    • default
    • latest
    • preview
    • Or, specific versions like 13.0, 12.0, 11.0, etc.
  7. 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

Hot Topics