加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 如果word长于X,则用点替换字符串的结尾

发布时间:2020-12-16 00:23:12 所属栏目:百科 来源:网络整理
导读:如果它比X字符更长,我如何格式化Razor CS HTML页面中的字符串: p@Model.Council/p Example for an X = 9- if Council is "Lisbon",then the result is "pLisbon/p"- if Council is "Vila Real de Santo António",then the result is "pVila Real.../p" wit
如果它比X字符更长,我如何格式化Razor CS HTML页面中的字符串:

<p>@Model.Council</p> 

Example for an X = 9

-> if Council is "Lisbon",then the result is "<p>Lisbon</p>"
-> if Council is "Vila Real de Santo António",then the result is "<p>Vila Real...</p>" with the title over the <p> "Vila Real de Santo António" showing the complete information

谢谢.

解决方法

任何字符串. See here.

而对于你的代码……

@(Model.Council.Length>10 ? Model.Council.Substring(0,10)+"..." : Model.Council)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读