如何以字符串格式c添加{ [英] how to add { in String Format c#
本文介绍了如何以字符串格式c添加{的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图像这样格式化字符串,{Enum.Enum1,"Enum1String"}我尝试了这段代码
I was trying to format string like this, {Enum.Enum1,"Enum1String"} I tried this code
foreach (KeyValuePair<int, string> p in Helper.Dict)
{
// file.WriteLine(string.Format("{0} | {1}",p.Key,p.Value));
file.WriteLine(string.Format("{Enum.{0},\"{1}\"}", p.Value,p.Value));
}
但是它不起作用.如何以字符串格式添加{.我正在考虑使用stringbuilder.
but it doesn not work. How to add { in string format. I am thinking to use stringbuilder.
推荐答案
来自以下 MSDN常见问题解答:
string s = String.Format("{{ hello to all }}");
Console.WriteLine(s); //prints '{ hello to all }'
这篇关于如何以字符串格式c添加{的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文