Escaping a { into a format string

  • Thread starter Thread starter Ralph Mason
  • Start date Start date
R

Ralph Mason

Pretty simple question here.

If I do a format and I want to incluide a { or a } how do I go about it. It
seems you can't eacape it with a backslash.

Sofar all I have done is string.Format("{0}","{"); Is there a better way?

Thanks
Ralph
 
A said:
You can also do:
string s = @"{0}";

That won't help. The @ only makes a difference at compile-time, and the
compiler doesn't care about { or } in a string.

For instance:

Console.WriteLine ("{0}", 1);
is the same as
Console.WriteLine (@"{0}", 1);
 
Back
Top