asp.net String.format中大括号的加入方法_asp.net教程-查字典教程网
asp.net String.format中大括号的加入方法
asp.net String.format中大括号的加入方法
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:String.Format("{0}world!","hello")//将输出helloworld!,没有问题,但是只要在...

复制代码 代码如下:

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!

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新asp.net教程学习
    热门asp.net教程学习
    编程开发子分类