When we use curly braces in the string.Format its not working in C#?

Asked 8 years ago
Updated 8 years ago
Viewed 1176 times

3

When we use curly braces in the string.Format its not working in C#?

below is my code:

string functionName="Add";

string.Format("function {0}(args) { return false; }", functionName);

Please help me!.

asked by Anonymous User , modified by Anonymous User in programming

1 Answer


2

Hi Tarun,

I just want to let you know that you are doing simple mistake as you are applying "{return false;}" but actually you should apply "{{ return fasle ;}}". it will definitely work!!.

string functionName="Add";

string.Format("function {0}(args) {{ return false; }}", functionName);
answered 8 years ago by Anonymous User

Your Answer