Razor: No overload for method 'Write' take

2019-03-22 18:42发布

@{ 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!

标签: c# razor
1条回答
放荡不羁爱自由
2楼-- · 2019-03-22 18:59

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++;
}
查看更多
登录 后发表回答