我的字符串构建器,用于创建JSON Reply:
List<string> aList = getList();
StringBuilder StrBuilder = new StringBuilder();
StrBuilder.Append("\"length\":\"");
StrBuilder.Append(aList.Count.ToString());
int i = 1;
foreach (string str in aList)
{
StrBuilder.Append("\", \"File" + i + "\":\"");
StrBuilder.Append(str.ToString());
i++;
}
我不知道错误在哪里,但我收到以下错误:
答案 0 :(得分:0)
List<string> aList = getList();
StringBuilder StrBuilder = new StringBuilder();
StrBuilder.Append("{\"length\":\"");
StrBuilder.Append(aList.Count.ToString());
int i = 1;
foreach (string str in aList)
{
StrBuilder.Append("\", \"File" + i + "\":\"");
StrBuilder.Append(str.ToString());
i++;
}
StrBuilder.Append("\"}");
需要关闭“并需要添加{}。