Razor if condition difference
Why is the second if statement incorrect? note that I attempted to make it a single line.
thanks
After Andrei Andrushkevich suggestion, red code. Tree and ul are red/squiggled. Plus the function param is red an开发者_如何学编程d all references in the blurred code is red.
The @:
sequence indicates that the entire line of content that follows should be treated as a content block.
So @if (condition) { @: Some content }
won't work because the last bracket is interpreted as content and another ending }
will be expected.
For single line conditions you can use the <text>
tag:
@if (condition) { <text>Some content</text> }
Remove first symbol "@" from the second condition.
精彩评论