復制代碼 代碼如下:
String.Format("{0} world!","hello") //將輸出 hello world!,沒有問題,但是只要在第一個參數的任意位置加上一個大括號:
String.Format("{0} wo{rld!","hello") //就會產生一個異常,異常信息是:Input string was not in a correct format.
//解決辦法:String.Format("{0} wo{{rld!","hello")
//or
String.Format("{0} wo{1}rld!","hello","{")
//它們都將輸出 hello wo{rld!