Concatenating strings in Razor

前端 未结 5 1482
忘了有多久
忘了有多久 2020-12-24 04:28

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

5条回答
  •  独厮守ぢ
    2020-12-24 04:46

    You can use:

    @foreach (var item in Model)
    {
      ...
      @Html.DisplayFor(modelItem => item.address + " " + item.city) 
      ...
    

提交回复
热议问题