今天在format一个json串的时候,老是提示说字符串格式有问题,纠结了好一会,试来试去不对。
就当我要放弃改用+的时候,我想到了还有Google,呵呵。
原来想要format带大括号的要输入两个大括号来表示一个大括号,就像要输入一个“\”要用两个“\”来表示。
所以,正确的应该是
string temp = "{{\"page\":\"{0}\",\"page_size\":\"{1}\"}}";
temp=string.Format(temp, 1, 20);
这种形式。
Good Luck。Sheldon