2

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

Console.WriteLine("{0} \{\}", "Hello");
R.D
  • 4,659
  • 11
  • 39
  • 56

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
  • 156,697
  • 29
  • 278
  • 282
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
  • 119,149
  • 26
  • 217
  • 245