串联在剃刀字符串。 [英] Concatenating strings in Razor.

查看:111
本文介绍了串联在剃刀字符串。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将如何连接两个字符串剃刀语法?

How would I join two strings in Razor syntax?

如果我有: @ Model.address @ Model.city 和我想的出来把要地址城市该怎么办?它是那样简单做 @ Model.address ++ @ Model.city

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?

推荐答案

使用剃刀的parentesis语法:

Use the parentesis syntax of Razor:

@(Model.address + " " + Model.city)

@(String.Format("{0} {1}", Model.address, Model.city))

这篇关于串联在剃刀字符串。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆