问题:

我试图以.NET 4.6为目标,并通过将C#语言版本更改为6来利用最新的C#版本。

但是在编译期间我遇到了这个错误:

错误无效选项’6’表示/ langversion; 必须是ISO-1,ISO-2,3,4,5或默认值

如果我将Web.Config设置中的/langversion:6更新为5,它可以工作,

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701">

但是如何在不使用低语言版本的情况下解决这个问题呢?

我正在使用Visual Studio 2015社区版,我还手动安装了.NET Framework 4.6,以防Visual Studio 2015默认安装它。

该项目是Visual Studio 2015创建的标准ASP.NET MVC模板项目。

I am trying to target .NET 4.6 and also take advantage of the latest C# version by changing the C# language version to 6.However during compilation I got this error:Error Invalid option ‘6’ for /langversion;must be ISO-1, ISO-2, 3, 4, 5 or DefaultIf I update the /langversion:6 in Web.Config setting to 5 it works,But how do I resolve this without resorting to lower language version?I am using Visual Studio 2015 Community Edition, and I have also installed .NET Framework 4.6 manually just in case it was not installed by default by Visual Studio 2015.The project is a standard ASP.NET MVC template project created by Visual Studio 2015.