gpt4 book ai didi

asp.net-mvc-3 - 在 Visual Studio 10 ASP.NET MVC3 中使用

转载 作者:行者123 更新时间:2023-12-03 01:57:06 24 4
gpt4 key购买 nike

我正在使用 Visual Studio 2010 专业版在 ASP.NET MVC3 框架中开发应用程序。

我遇到过一种情况,我需要一个文字空格字符,通常通过在 HTML 中添加   (类似的东西)来完成。

但是,程序出现运行时错误。

如何克服这个问题?

代码:

<div class="week">
@for (int i = 0; i < 7; i++)
{
<div class="day">
@weekStartDay.ToString().Substring(0, 3)
</div>
&nbsp;
weekStartDay = (DayOfWeek)(((int)weekStartDay + 1) % 7);
}
</div>

错误:

c:***\Documents\Visual Studio 2010\Projects\MvcApplication2\MvcApplication2\Views\Home\Calendar.cshtml(22): 错误 CS0201: 只能赋值、调用、递增、递减和新对象表达式用作声明

最佳答案

将代码更改为

<div class="week">
@for (int i = 0; i < 7; i++)
{
<div class="day">
@weekStartDay.ToString().Substring(0, 3)
</div>
@:&nbsp;
weekStartDay = (DayOfWeek)(((int)weekStartDay + 1) % 7);
}
</div>

@:告诉 Razor View 引擎   是纯文本

关于asp.net-mvc-3 - 在 Visual Studio 10 ASP.NET MVC3 中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13796503/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com