Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to ignore { character?

Tags:

c#

.net

I would like to ignore { character in string is it possible ?

thanks for help

String.Format("function(s, e) {  {0}.PerformCallback(MyObject.GetSelectedItem().value); }", getClientName);
like image 649
gruber Avatar asked Jan 26 '26 02:01

gruber


2 Answers

You have to double the curly braces in order to escape them:

String.Format(CultureInfo.InvariantCulture, @"
    function(s, e) {{
        {0}.PerformCallback(MyObject.GetSelectedItem().value);
    }}", getClientName);
like image 166
Frédéric Hamidi Avatar answered Jan 28 '26 15:01

Frédéric Hamidi


You can escape the curly brace by typing {{ and it will display as one.

like image 32
Patrick Avatar answered Jan 28 '26 17:01

Patrick