Razor: No overload for method 'Write' takes 0 arguments

C#Razor

C# Problem Overview


@{ 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# Solutions


Solution 1 - C#

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++;
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIan DavisView Question on Stackoverflow
Solution 1 - C#ZoteView Answer on Stackoverflow