C# 剃刀:方法'没有过载;写';接受0个参数
我在代码的@{I++;}行上得到“方法'Write'不重载0个参数”。有什么想法吗?谢谢 试试这个:C# 剃刀:方法'没有过载;写';接受0个参数,c#,razor,C#,Razor,我在代码的@{I++;}行上得到“方法'Write'不重载0个参数”。有什么想法吗?谢谢 试试这个: @{ int i = 4; } @foreach (string s in "1,2,3".Split(',')) { @:s is equal to @s @{ i++; } } 或 @{int i=4;} @foreach(字符串s在“1,2,3”中)。拆分(',')){ 等于@s i++; } 只是为了澄清为什么这样做:一旦你进入了代码,你就不再需要@{}。您使用“@:”进入
@{ int i = 4; }
@foreach (string s in "1,2,3".Split(',')) {
@:s is equal to @s
@{ i++; }
}
或
@{int i=4;}
@foreach(字符串s在“1,2,3”中)。拆分(',')){
等于@s
i++;
}
只是为了澄清为什么这样做:一旦你进入了代码,你就不再需要@{}。您使用“@:”进入标记,但将其保留在行的末尾,这样您就又回到了代码中。
@{ int i = 4; }
@foreach (string s in "1,2,3".Split(',')) {
@:s is equal to @s
i++
}
@{ int i = 4; }
@foreach (string s in "1,2,3".Split(',')) {
<text>is equal to @s</text>
i++;
}