Morning,一早写了 N 多的 String.Format 忽然想起了这个历史遗留的问题如题所述,假如 System.String.Format(string format, object arg) 中
参数 format 本身也包含 { 或者 } 怎么办?有没有转义符支持?例如,常见的js脚本,// how to escape the { & } ?
string script = String.Format(@"window.onload = function() { alert(""{0}""); }", "Hello world!"); // -> System.FormatException: 输入字符串的格式不正确。any tips?thx in advance.
参数 format 本身也包含 { 或者 } 怎么办?有没有转义符支持?例如,常见的js脚本,// how to escape the { & } ?
string script = String.Format(@"window.onload = function() { alert(""{0}""); }", "Hello world!"); // -> System.FormatException: 输入字符串的格式不正确。any tips?thx in advance.
解决方案 »
- 手动绑定GridView时,日期格式的设定
- 请教 网站发布后调用c++的dll控件报错,调试却没有问题.???
- 用户登录的异常“主机名\ASPNET",我用的是WINDOWS集成认证
- 各位高手看看吧,我都郁闷半天了
- 再散100分,关于如何在ie浏览器中察看word文档内容(包含图片)。注意,这里察看不是指使用word环境,而是使用类似image或者textbox控件
- 向数据库大批量数据插入时,始终保持一个连接是否更好?
- ASP.NET如何实现客户端缓存并保证与服务器同步
- 关于在网页中调用第三方控件的问题
- 关于WorkFlow Fundations
- 【汇总】SQL CODE --- 经典·精彩
- 我想要一种效果:用javascript 和div 实现展开和收缩 div 层的功能!100 分,必结贴!
- 关于asp.net 发布网站不成功问题?
Response.Write(str);
正则表达式Replace的时候,用$$对$进行转义比较特殊的转义方法,只见过DateTime的ToString方法里,是用''包含",也就是'"'这种方式对"进行转义的
你对
else
这样转也没用啊或者如何实现楼主想要实现的?
string test = "{0}";
string script= String.Format(@test, "Hello world!");Label1.Text = script;
string script= String.Format(test, "Hello world!");Label1.Text = script;
luomingchao完全不知道这位同志在这里自言自语什么……
同意
http://msdn2.microsoft.com/zh-cn/library/txafckwd(VS.80).aspx