What is the best practice when you have to use a razor variable but you cannot have a space after it ?
eg.
@foreach (var photo in Model.Photos)
{
<a style="width:@photo.ThumbWidth px;" href="..."><img....></a>
}
I don't want the space before "px"
- a method in the Model class that build the string ?
- String.Concat ?
- String interpolation with $ ?
Thanks
CodePudding user response:
Parentheses:
@foreach (var photo in Model.Photos) {
<a style="width:@(photo.ThumbWidth)px;" href="..."><img....></a>
}