开发者

Razor if condition difference

开发者 https://www.devze.com 2023-03-18 19:32 出处:网络
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

Why is the second if statement incorrect? note that I attempted to make it a single line.

Razor if condition difference

Razor if condition difference

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.

Razor if condition difference


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消