Home > database >  Visual Studio 2022 Community: Stuck with C# language version 7.3?
Visual Studio 2022 Community: Stuck with C# language version 7.3?

Time:12-06

Trying to use sample code from the book "Learn C# programming..." by Bancila and Sharma. When I try to build the project, I get error messages saying that certain features are not available in C# 7.3, and that I should upgrade to C# 9.0 resp. 10.0. However, there is no way to change the language version. When I go to Project Properties/Build/Advanced, the language version shows frozen. Also, adding the line "<LangVersion>10.0</LangVersion>" in the .csprog file seems to have no effect. Can somebody help or at least explain? Thanks!

I added the line "<LangVersion>10.0</LangVersion>" in the .csprog file. But the problem remains.

CodePudding user response:

The C# version depends on the .NET / .NET Framework version you are using.

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version

CodePudding user response:

You'll need to download the relevant SDk to have access to newer versions of C#.

For C# 9, you need the .NET 5 SDK.

You can find it here:

https://dotnet.microsoft.com/en-us/download/dotnet

CodePudding user response:

The book is targeted for C# 8 i.e. net core 3, so I would recommend just creating a project for .Net 6 or 7. These should be fully backward compatible with .net Core 3. In the visual studio installer you can select what specific .Net versions you want to include support for. I would expect .Net 6 to be installed by default, but it is easy to check.

  •  Tags:  
  • c#
  • Related