2

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

Console.WriteLine("{0} \{\}", "Hello");
R.D
  • 4,781
  • 11
  • 41
  • 58

3 Answers3

5

You need to use double parenthesis.

Something like

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

First question at

String Formatting FAQ

Adriaan Stander
  • 162,879
  • 31
  • 289
  • 284
2

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

Community
  • 1
  • 1
1
Console.WriteLine("{0} {{}}", "Hello");
Anthony Pegram
  • 123,721
  • 27
  • 225
  • 246