我的C#类
public class City
{
public int City_id { get; set; }
public string City_name { get; set; }
}
public class Model
{
public City[] lstCitiesResult { get; set; }
}
我的代码:
namespace gtp2
{
....
List<Model> li = new List<Model>();
WebClient re = new WebClient();
var data = re.DownloadString("url");
var a = JsonConvert.DeserializeObject<Model>(data);
Response.Write(a.lstCitiesResult.ToString());
....
}
在 Response.Write 我是这样的:gtp2.City []任何Ideya?提前感谢
答案 0 :(得分:0)
看起来结果是City
的数组,所以你需要遍历它。但是你可以用一个处理收集的控件来显示它,例如ListView,DataList等试试这个:
string output = "";
foreach(var c in a.lstCitiesResult)
{
output = output + String.Format("id: {0}, name: {1}", c.City_id, c.City_name);
}
Response.Write(output);