有没有办法在通话中使用的格式字符串的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页面上的转义大括号一节综合格式化了解更多详细信息