How can brackets be escaped in using string.Format?
For example:
String val = "1,2,3" String.Format(" foo {{0}}", val);
This example doesn’t throw an exception, but it outputs the string foo {0}.
Is there a way to escape the brackets?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For you to output
foo {1, 2, 3}you have to do something like:To output a
{you use{{and to output a}you use}}.Or now, you can also use C# string interpolation like this (a feature available in C# 6.0)
Escaping brackets: String interpolation $(""). It is new feature in C# 6.0.