string Format轉義大括號


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!


轉自:http://www.cnblogs.com/hanyun/archive/2012/04/17/2453881.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM