开发者

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

开发者 https://www.devze.com 2022-12-28 16:46 出处:网络
I want to see, Hello {} in the output, but the following gives compiler errors Console.WriteLine(开发者_如何学C\"{0} \\{\\}\", \"Hello\");

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

精彩评论

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