Concatenating strings in Razor
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
?
Use the parentesis syntax of Razor:
@(Model.address + " " + Model.city)
or
@(String.Format("{0} {1}", Model.address, Model.city))
Update: With C# 6 you can also use the $-Notation (officially interpolated strings):
@($"{Model.address} {Model.city}")
String.Format also works in Razor:
String.Format("{0} - {1}", Model.address, Model.city)
You can give like this....
<a href="@(IsProduction.IsProductionUrl)Index/LogOut">