if else statement in Razor is not functioning

前端 未结 4 900
轻奢々
轻奢々 2021-02-05 05:01

I am using an if else in Razor view to check for null value like this:

 @foreach (var item in Model)
    {
        
                  


        
4条回答
  •  日久生厌
    2021-02-05 05:33

    There are actually two other ways to display text from a code block in razor besides the suggested @(""), using a tag and it's shorthand @:

        @{
            @("--")
            --
            @:--
        }
    

    The code above will display -- three times.

提交回复
热议问题