string.format format string containing {

后端 未结 5 761
半阙折子戏
半阙折子戏 2020-12-07 04:31

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 th

5条回答
  •  鱼传尺愫
    2020-12-07 05:15

    Yup, you just need to double it:

    string.Format("my format has this {{ in it {0}", abc);
    

    See the "escaping braces" section on the MSDN page for Composite Formatting for more details.

提交回复
热议问题