How to escape brackets in .Net Programming?
Published on 06 December 12
2495
0
How can brackets be escaped in a C# format string?
For example:
String val = "1,2,3" String.Format(" foo {{0}}", val);
To escape the brackets such that it doesn't throw a parse exception but still outputs the string " foo {1,2,3}"
Solutions:
Using {{ . it is treated as an escape bracket tool in a format string.
For you to output foo {1, 2, 3} you have to do something like:
string t = "1, 2, 3"; string v = String.Format(" foo {{{0}}}", t); ;
This review is listed under
Development & Implementations
Community
Related Posts:
Post a Comment