Output '{' or '}' with string.format(...)

c#, string

Solution

Use `{{` and `}}`. So your example would be `string.Format("{{Hello World}}");`

Problem

I bet that's an easy question for you, but searching SO or Google with `{` or `}` in the search string doesn't work very well. So, let's say i wanna output `{Hello World}`, how do i do this using `string.format(...)`? Edit: looks like this: ``` string hello = "Hello World"; string.format("{0}", '{' + hello + '}'); ``` would do the job, but that doesn't look very elegant to me. Is there a way to escape these characters inside the format string?

Original source