我试图使用三元运算在这一段代码,其中Model.FirstTechSupportAssigneeElapseTime
是TimeSpan?
类型:如何使用@Model(TimeSpan)在剃须刀中使用三元运算符?
<dt>Assigned In</dt>
<dd>
@if (@Model.FirstTechSupportAssigneeElapseTime == null)
{ @:N/A }
else
{ @Model.FirstTechSupportAssigneeElapseTime }
</dd>
我试图实现三元运算符,但我没有草草收场时,@的无处不在令我困惑。在这种情况下可以有三元运算符吗?
谢谢。
其实ElapseTime是一个TimeSpan,它对此抱怨操作符?不能应用于TimeSpan和字符串。 – 2015-02-06 00:23:54
@GuillermoSánchez - 如果在时间范围内使用'.ToString()',那么''''''''''可能还不能很好地运行三元运算符(请参阅我的编辑) – 2015-02-06 00:25:10
它告诉我“左手“operator shoild be reference or nullable time”这很奇怪,因为EllapseTime声明是这样的:public TimeSpan? FirstTechSupportAssigneeElapseTime {get;私人设置; } – 2015-02-06 00:28:42