zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

asp.netString.format中大括号的加入方法

ASP方法 加入 format 大括号
2023-06-13 09:14:18 时间

复制代码代码如下:


String.Format("{0}world!","hello")//将输出helloworld!,没有问题,但是只要在第一个参数的任意位置加上一个大括号:
String.Format("{0}wo{rld!","hello")//就会产生一个异常,异常信息是:Inputstringwasnotinacorrectformat.
//解决办法:String.Format("{0}wo{{rld!","hello")
//or
String.Format("{0}wo{1}rld!","hello","{")
//它们都将输出hellowo{rld!