Little Known Fact: How do you Escape a Curly Brace in a Format String?

Friday, 20 July 2007 19:48 by tariq

Needing to spew out some javascript as a format template I ran into the issue of how do you escape a curly brace for String.Format.

Obviously \{ doesnt work.

Googling around brought me to this Forum.

Guess what a double curly brace works.

So the format string becomes

  • "function foo(){{ document.write("{0}"); }}"

 

Technorati tags: , ,
Categories:  
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed
Comments are closed