Difference between ( ) (parenthesis) and { } (curly brackets) in Razor

前端 未结 3 733
孤街浪徒
孤街浪徒 2021-02-05 03:51

What is the difference between them both. I thought they were the same but today I realized that they are not.

Why this is correct

@(Model.WillAttend ==         


        
3条回答
  •  故里飘歌
    2021-02-05 04:47

    The paren is just an explicit expression, and you will notice that you do not need a semi-colon. The brackets are a code block, to be used just like any other piece of code. Expressions have their output submitted as part of the HTML, whereas code blocks do not.

    Phil Haack actually wrote a good primer on some Razor syntax

提交回复
热议问题