Today, I wrote a short piece of code during project development:
Sb_result.appendformat ("{\" smsmtaskmodename \ ": \" {0} \ ", \" smempname \ ": \" {1} \ "", DT. rows [0] ["smsmtaskmodename"]. tostring (), DT. rows [0] ["smsmempname"]. tostring ());
Note that the red {can be compiled successfully. When the code is executed here, the message "input string was not in a correct format" is incorrect.
Remove the red.
Clever handling: sb_result.appendformat ("{2} \" smsmtaskmodename \ ": \" {0} \ ", \" smsmempname \ ": \" {1 }\"", DT. rows [0] ["smsmtaskmodename"]. tostring (), DT. rows [0] ["smsmempname"]. tostring (),"{");
This is OK ..
Look at Microsoft's official: http://msdn.microsoft.com/en-us/library/txafckwd.aspx
Each format item takes the following form and consists of the following components:
{Index [, alignment] [: formatstring]}
The matching braces ("{" and "}") are required.
A small problem with stringbuild