2017-04-25 90 views
0

看来Razor并不了解ValueTuple。在我的剃须刀页:ASP.NET Core MVC中的ValueTuple

@{ 
    var x = (1, "a"); 
} 

上面的代码给我:

An error occurred during the compilation of a resource required to process 
this request. Please review the following specific error details and modify 
your source code appropriately. 

enter image description here

我尝试相同的代码在我的控制器,它的工作,我已经加入我的csproj以下:

<PackageReference Include="System.ValueTuple" Version="4.3.0" /> 

UPD ATE

我加了这一点,但仍然没有工作:

<PackageReference Include="Microsoft.Net.Compilers" Version="2.1.0" /> 
+2

其他C#7功能是否可以在Razor中使用?我想知道是否需要为C#编译器本身添加一个包...尝试'object o = null;如果(o是字符串x){}' –

+0

我会尝试,坚持下去。 – dpp

+0

@JonSkeet不,他们不是。我试过'var d = 0xAB_CD_EF;'和你给我的代码。 – dpp

回答