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

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

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

      

+2


a source to share


3 answers


You need to use double brackets.

Sort of

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

      



First question in

Frequently asked questions about string formatting

+5


a source


Using double brackets. See How to avoid parentheses (curly braces) in a format string in .NET , eg.



+2


a source


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

      

+1


a source







All Articles