ASP.NET vbhtml with razor syntax 给出了 DateTime.Now.DayOfWeek 的错误答案?

ASP.NET vbhtml with razor syntax gives wrong answer for DateTime.Now.DayOfWeek?

<!-- Multi-statement block --> 
@Code
dim greeting = "Welcome to our site!" 
dim weekDay = DateTime.Now.DayOfWeek 
dim greetingMessage = greeting & " Here in Huston it is: " & weekDay
End Code

<p>The greeting is: @greetingMessage</p> 

星期几显示“4”,这是当前月份,但单独使用时没有像这样的“&”

dim greetingMessage = weekDay

<p>@DateTime.Now.DayOfWeek</p>

然后它显示正确的工作日。

两种方式都是一样的。在第一种情况下,4 不是月份。这是星期四的号码。使用 weekDay.ToString()。

 <!-- Multi-statement block -->
    @Code
        Dim greeting = "Welcome to our site!"
        Dim weekDay = DateTime.Now.DayOfWeek
        Dim greetingMessage = greeting & " Here in Huston it is: " & weekDay.ToString()
    End Code