<p>How can brackets be escaped in using <code>string.Format</code>?</p>
<p>For example:</p>
<pre><code>String val = &quot;1,2,3&quot;
String.Format(&quot; foo {{0}}&quot;, val);
</code></pre>
<p>This example doesn't throw an exception, but it outputs the string <code>foo {0}</code>.</p>
<p>Is there a way to escape the brackets?</p>

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);
```
```
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.
```
```
var inVal = "1, 2, 3";
var outVal = $" foo {{{inVal}}}";
// The output will be:  foo {1, 2, 3}
```
```