问题
I have a solution that contains five C# console application projects. I would like each project to target a different version of C#.
MyLearningSolution.sln
CSharp01.csproj
CSharp02.csproj
CSharp03.csproj
CSharp04.csproj
CSharp05.csproj
Is there a way to do this either via Visual Studio or via editing each csproj file?
I have tried the following searches:
csproj target specific C# version, this talks about targeting a specific framework version
csproj choose c# version, doesn't answer the question
回答1:
This can be done by looking at the <LangVersion> element of the csproj file. Possible values:
<LangVersion>default</LangVersion>
<LangVersion>ISO-1</LangVersion>
<LangVersion>ISO-2</LangVersion>
<LangVersion>3</LangVersion>
<LangVersion>4</LangVersion>
<LangVersion>5</LangVersion>
To do it via the UI, go to Project Properties => Build => Advanced... => Language Version
回答2:
Right click on Project, go to Properites, There under Build click the Advanced.. button, there you can specify Language version.
来源:https://stackoverflow.com/questions/28859651/make-each-csproj-in-a-solution-target-a-different-c-sharp-version