Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 剃刀:方法'没有过载;写';接受0个参数_C#_Razor - Fatal编程技术网

C# 剃刀:方法'没有过载;写';接受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++; } 只是为了澄清为什么这样做:一旦你进入了代码,你就不再需要@{}。您使用“@:”进入

我在代码的@{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 (string s in "1,2,3".Split(',')) {
   <text>is equal to @s</text>
   i++;
}