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 == true ?
"This will be an exciting party with you" :
"So sorry. You'll lose the beeer")
and this is not:
@{Model.WillAttend == true ?
"This will be an exciting party with you" :
"So sorry. You'll lose the beeer"}
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