I have a class project , and im facing the the problem of the C# language version .
I tried to udate it to version 9 or 10 but it still at 7.3
and im using visual studio 2002 by the way
i need a solution please
Visual Studio will use the C# language as specified by the framework. This is documented here.
You can override by adding the
LangVersion element to your project file. But this may or may not work. What is implemented by the compiler and what requires runtime support has been blurred. Therefore even if you get the code to compile it might not necessarily run.
Finally note that to support C# 10 you'll need to be running the version of the build that supports it which means you'll need at least VS 2022. Even if you set the lang version to a valid value if MSBuild doesn't support it because it is too old then it won't work.
C# 7.3 is the highest version supported by the 4.8 framework or .net standard 2.0. To use a later version of c# you must convert the project to .net core. To use c# 10, you need the project to be net 6
Note: this is because starting with c# 8, the compiler requires .net runtime changes for each version, so c# version and runtime are tied together.
You will need to upgrade you visual studio to use a later version of c#
If using .NET Core you can double click on the project file in solution explorer and replace contents with
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <LangVersion>9.0</LangVersion> <TargetFramework>net5.0</TargetFramework> </PropertyGroup> </Project>
But not for a .NET Framework project e.g. 4.8
9 people are following this question.