How can brackets be escaped in using string.Format
.
For example:
String val = \"1,2,3\"
String.Format(\" foo {{0}}\", val);
Escaping curly brackets AND using string interpolation makes for an interesting challenge. You need to use quadruple brackets to escape the string interpolation parsing and string.format
parsing.
string localVar = "dynamic";
string templateString = $@"{0}
this is my {localVar} template using a {{{{custom tag}}}}";
string result = string.Format(templateString, "String Interpolation");
// OUTPUT: String Interpolation
this is my dynamic template using a {custom tag}