βIf you want to use new C# features like raw string literals (C# 11) or pattern matching improvements, you need to set the correct C# language version in your project.
Instead of setting it manually in every .csproj
file, you can apply it globally using a file called Directory.Build.props
.
This is the folder where your .sln
file is located.
Make sure to name it exactly like that (case-sensitive on Linux/macOS).
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>
You can replace latest
with a specific version like 11.0
, 12.0
, or preview
.
Now all projects under the solution will automatically use that C# version, without needing to modify each .csproj
.
Thatβs it! This is a clean and easy way to control your C# language version across the whole solution.