Skip to content

Commit 233ccc8

Browse files
author
Adit Sheth
committed
Fixed bug 43428.
1 parent 9a5a3b3 commit 233ccc8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/csharp/language-reference/configure-language-version.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ If you must specify your C# version explicitly, you can do so in several ways:
2222
>
2323
> To know what language version you're currently using, put `#error version` (case sensitive) in your code. This makes the compiler report a compiler error, CS8304, with a message containing the compiler version being used and the current selected language version. See [#error (C# Reference)](preprocessor-directives.md#error-and-warning-information) for more information.
2424
25+
## Why can't I select a different C# version?
26+
27+
In Visual Studio, the option to change the language version through the UI may be disabled because the default version is aligned with the project's target framework (`TFM`). This default configuration ensures compatibility between language features and runtime support.
28+
29+
For example, changing the target `TFM` (e.g., from [.NET 6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) to [.NET 9](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)) will update the language version accordingly, from C# 10 to C# 13. This approach prevents issues with runtime compatibility and minimizes unexpected build errors due to unsupported language features.
30+
31+
If you need a specific language version that differs from the one automatically selected, refer to the methods below to override the default settings directly in the project file.
32+
2533
## Edit the project file
2634

2735
You can set the language version in your project file. For example, if you explicitly want access to preview features, add an element like this:

0 commit comments

Comments
 (0)