试图填充表数据:剃刀语法
@foreach (var mc in Model.McList)
{
<tr>
<td>
@(@mc.Amount != null ? @mc.Amount @@ @mc.Price : null)
</td>
</tr>
}
,但卡在剃刀语法错误:
期待:
预期)
或模棱两可invocation:void编写
金额是int?可空类型。
@(@mc.Amount != null ? @mc.Amount : null) //works only with one property
@if (@mc.Amount != null) {@mc.Amount <text>@@</text> @mc.Price} //works
@if (@mc.Amount != null) {@mc.Amount @@ @mc.Price} //error
@if (@mc.Amount != null) {@mc.Amount @:@@ @mc.Price} //error
检查空值的方法是否更简短?
什么是具体的错误?我会说d.Price不是int(十进制) – Pedro
当然,价格是十进制的。我想获得类似的输出:例如'120 @ 30.50' – Arvis
HTML.Raw()在这里有帮助吗? – Matt