开发者

How to include parenthesis for AS-IS output in format string

I want to see, Hello {} in the output, but the following gives compiler errors

Console.WriteLine(开发者_如何学C"{0} \{\}", "Hello");


You need to use double parenthesis.

Something like

string s = String.Format("{0} {{}}", "Hello"); 

First question at

String Formatting FAQ


Using double brackets. See How to escape braces (curly brackets) in a format string in .NET for example.


Console.WriteLine("{0} {{}}", "Hello");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜