gpt4 book ai didi

c# - Razor 如果条件不同

转载 作者:太空狗 更新时间:2023-10-30 00:08:41 24 4
gpt4 key购买 nike

为什么第二个 if 语句不正确?请注意,我试图将其设为单行。

Correct If Condition

enter image description here

谢谢

根据 Andrei Andrushkevich 的建议,红色代码。树和 ul 是红色/波浪形的。另外,函数参数是红色的,模糊代码中的所有引用都是红色的。

enter image description here

最佳答案

@: sequence 表示后面的整行内容应该被视为一个内容 block 。

所以 @if (condition) { @: Some content }将不起作用,因为最后一个括号被解释为内容和另一个结尾 }将是预期的。

对于单行条件,您可以使用 <text>标签:

@if (condition) { <text>Some content</text> }

关于c# - Razor 如果条件不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6592852/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com