Razor: No overload for method 'Write' take

2019-03-22 18:27发布

问题:

@{ int i = 4; }
@foreach (string s in "1,2,3".Split(',')) {
   @:s is equal to @s
   @{ i++; }
}

I get "No overload for method 'Write' takes 0 arguments" on the @{ i++; } line of code. Any thoughts? Thanks!

回答1:

Try this:

@{ int i = 4; }
@foreach (string s in "1,2,3".Split(',')) {
   @:s is equal to @s
   i++
}

or

@{ int i = 4; }
@foreach (string s in "1,2,3".Split(',')) {
   <text>is equal to @s</text>
   i++;
}


标签: c# razor