MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.


I'm not curious

How to escape brackets in .Net Programming?

Published on 06 December 12
2342
0
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); ;


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:

C Sharp (C#)

 

parsing

 

DOT NET (.NET)

 

C# string

 

String

 

Formatting

 
Post a Comment

Please notify me the replies via email.

Important:
  • We hope the conversations that take place on MyTechLogy.com will be constructive and thought-provoking.
  • To ensure the quality of the discussion, our moderators may review/edit the comments for clarity and relevance.
  • Comments that are promotional, mean-spirited, or off-topic may be deleted per the moderators' judgment.
You may also be interested in
Awards & Accolades for MyTechLogy
Winner of
REDHERRING
Top 100 Asia
Finalist at SiTF Awards 2014 under the category Best Social & Community Product
Finalist at HR Vendor of the Year 2015 Awards under the category Best Learning Management System
Finalist at HR Vendor of the Year 2015 Awards under the category Best Talent Management Software
Hidden Image Url

Back to Top