In Asp.net MVC, Razor inserts extra space between text blocks. I want to render a list this way: “1, 2, 3” but get “1 , 2 , 3”.
@for (int i = 1; i < 3; i++)
{
<text>@i</text>
if (i != 2)
{
<text>, </text>
}
}
Is there any ways to remove extra whitespace ?
Quick and dirty:
Obviously a custom helper seems more appropriate to the job of formatting something in the view:
and then simply: