含有的String.Format格式化字符串{ [英] string.format format string containing {
本文介绍了含有的String.Format格式化字符串{的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在通话中使用的格式字符串的String.Format包含未用于子插入{字符?
Is there a way for the format string used in a call to string.format to contain a { character that is not used for substring insertion?
例如我怎么能做到这一点......
For example how could I do this...
string.format("my format has this { in it {0}", abc);
返回...
returning...
"my format has this { in it abc"
我要做到这一点,因为我创造了HTML,将孔坦的JavaScript脚本块的字符串。
I need to do this as the string I am creating in HTML and will contan a script block of javascript.
感谢您
推荐答案
是啊,你只需要双击它:
Yup, you just need to double it:
string.Format("my format has this {{ in it {0}", abc);
请参见 MSDN页面上的转义大括号一节综合格式化了解更多详细信息
这篇关于含有的String.Format格式化字符串{的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文