I'm trying to add space between two strings in razor file in Blazor project.
What I'm trying to achieve is to get string like $"{name}, {date}"
.
Its complicated because I want to set different style for {name} and {date}. So in razor file, I have something like
<span class="c1">@(name)</span>, <span class="c2">@(date)</span>
Unfortunately space between </span>,
and <span>
is ignored.
I also tried the following:
<span class="c1">@(name), </span><span class="c2">@(date)</span>
<span class="c1">@(name)</span><text>, </text><span class="c2">@(date)</span>
Every time I get "name,date" instead of "name, date"
I know I can achieve it by
@($"<span class=\"c1\">{name}</span>, <span class=\"c2\">{date}</span>")
//or
<span class="c1">@(name)@(", ")</span><span class="c2">@(date)</span>
//or
<span class="c1">@($"{name}, ")</span><span class="c2">@(date)</span>
//or maybe
<span class="c1">@name</span><span class="c2 ps-1">@(date)</span>
But is there any "clean" or preferred way just to not ignore the space key in such situations?