All about programming FU.
Curly braces and String.Format() in C#
Ever wanted to use String.Format on, say, a javascript function? Those include curly braces ( { or } ), but those curly braces are reserved as placeholder marker in String.Format() (i.e. for {0}). Escaping the braces with a backslash does not work.
The solution is pretty simple: You need to double those curly braces to escape them.
String.Format("function test() {{ return calcSomething({0}); }}", "123");
| Artikel drucken | Dieser Beitrag wurde von Sebastian P.R. Gingter am 2008/10/23 um 14:08 veröffentlicht und unter .NET, Software abgelegt. Du kannst allen Antworten zu diesem Beitrag durch RSS 2.0 folgen. Du kannst eine Antwort schreiben oder einen Trackback von deiner eigenen Seite hinterlassen. |