How would I join two strings in Razor syntax?
If I had: @Model.address
and @Model.city
and I wanted the out put to be address city
what would I do? Is it as simple as doing @Model.address + " " + @Model.city
?
How would I join two strings in Razor syntax?
If I had: @Model.address
and @Model.city
and I wanted the out put to be address city
what would I do? Is it as simple as doing @Model.address + " " + @Model.city
?
the plus works just fine, i personally prefer using the concat function.
var s = string.Concat(string 1, string 2, string, 3, etc)
Use the parentesis syntax of Razor:
or
Update: With C# 6 you can also use the $-Notation (officially interpolated strings):
You can give like this....
String.Format also works in Razor:
You can use: