【发布时间】:2012-11-26 02:55:28
【问题描述】:
可能重复:
String.Format exception when format string contains “{”
是否可以使用C# String.Format 进行以下操作?
需要的输出"products/item/{itemId}"
我试过转义大括号,但这不起作用:
const string itemIdPattern = "itemId";
string result = String.Format("products/item/{{0}}", itemIdPattern);
最好是比
更好的东西string result = String.Format("products/item/{0}{1}{2}",
"{",
itemIdPattern,
"}");
【问题讨论】:
标签: c# .net string.format