首页 > 其他 > 详细

string Format转义大括号:输入字符串的格式不正确。

时间:2015-11-18 15:37:45      阅读:231      评论:0      收藏:0      [点我收藏+]
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!

 

string Format转义大括号:输入字符串的格式不正确。

原文:http://www.cnblogs.com/gosky/p/4974553.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!