我有以下 Razor 代码部分,它在运行时失败并出现编译错误:
@foreach(var stat in Model){
<li>
@stat.EffectiveDate.ToShortDateString() - @stat.EventType.Description <br />
TimeTaken:
@if (@stat.TimeTaken.Hours > 0) {
@stat.TimeTaken.Hours hours
}
@stat.TimeTaken.Minutes minutes
@stat.TimeTaken.Seconds seconds.
</li>
}
错误@stat.TimeTaken.Hours hours
在线
CS1002: ; 预期的
删除文字hours
修复它。
我很困惑。
编辑:这是从“@if”到“seconds”的编译输出。
Line 180: if (@stat.TimeTaken.Hours > 0) {
Line 181:
Line 182:
Line 183: #line default
Line 184: #line hidden
Line 185:
Line 186: #line 29 "c:\documents and settings\dave\my documents\visual studio 2010\Projects\SportStats\SportStats\Views\Stats\Index.cshtml"
Line 187: this.Write(stat.TimeTaken.Hours);
Line 188:
Line 189: #line default
Line 190: #line hidden
Line 191:
Line 192: #line 29 "c:\documents and settings\dave\my documents\visual studio 2010\Projects\SportStats\SportStats\Views\Stats\Index.cshtml"
Line 193: hours
Line 194: }
Line 195:
Line 196:
Line 197: #line default
Line 198: #line hidden
Line 199:
Line 200: #line 31 "c:\documents and settings\dave\my documents\visual studio 2010\Projects\SportStats\SportStats\Views\Stats\Index.cshtml"
Line 201: this.WriteLiteral("\t\t\t\t");
Line 202:
Line 203: #line default
Line 204: #line hidden
Line 205:
Line 206: #line 31 "c:\documents and settings\dave\my documents\visual studio 2010\Projects\SportStats\SportStats\Views\Stats\Index.cshtml"
Line 207: this.Write(stat.TimeTaken.Minutes);
Line 208:
Line 209: #line default
Line 210: #line hidden
Line 211:
Line 212: #line 31 "c:\documents and settings\dave\my documents\visual studio 2010\Projects\SportStats\SportStats\Views\Stats\Index.cshtml"
Line 213: this.WriteLiteral(" minutes \r\n\t\t\t\t");
Line 214:
Line 215: #line default
Line 216: #line hidden
Line 217:
Line 218: #line 32 "c:\documents and settings\dave\my documents\visual studio 2010\Projects\SportStats\SportStats\Views\Stats\Index.cshtml"
Line 219: this.Write(stat.TimeTaken.Seconds);
Line 220:
Line 221: #line default
Line 222: #line hidden
Line 223:
Line 224: #line 32 "c:\documents and settings\dave\my documents\visual studio 2010\Projects\SportStats\SportStats\Views\Stats\Index.cshtml"
Line 225: this.WriteLiteral(" seconds.\r\n\t\t\t</li>\r\n");