System.FormatException of a string

c#, formatexception, string.format

Solution

I think you want:

var val = string.Format("\"{0}\" : {{ {1} }}", arrayName, fieldList);

Note the doubled `{{` and `}}` which is the escape sequence necessary to get braces literally into the output.

Problem

I'm getting System.FormatException: Input string was not in a correct format when running this method. The values of the fields: ``` arrayName = "requester"; fieldList = "\"name\" : \"shimshon\""; // "name" : "shimshon" public override string ToString() { var val = string.Format("\"{0}\" : { {1} }", arrayName, fieldList); return val; } ``` the expect result of the method is ``` "requester" : { "name" : "shimshon" } ``` What is wrong with this format?

Original source

Related problems