我需要有2个列表(列表A和列表B),列表的数据源都是JSON数组对象,列表A包含来自JSON响应和列表的所有记录B包含它的一个子集,它基于对象的状态类型。这是我到目前为止有:将对象添加到列表中c#-windows phone
public class Result
{
public int request_id { get; set; }
public string createdTime { get; set; }
public string status { get; set; }
}
public class RootObject
{
public List<Result> result { get; set; }
}
我为解析它使用JSON.NET和填充列表A
var responseString = await response.Content.ReadAsStringAsync();
RootObject rootoject = JsonConvert.DeserializeObject<List<RootObject>>(responseString)[0];
ListBox1.ItemsSource = rootoject.result;
基于此状态的记录
林查询列表
HashSet<Result> sample = new HashSet<Result>(rootoject.result.Where(item
=> item.status == "approved"));
List<RootObject> approvedlist = new List<RootObject>();
**approvedlist.Add(sample); Getting error here cannot convert from hashset to Rootobject**
我试过
RootObject sample=new HashSet<Result>(rootoject.result.Where(item
=> item.status == "approved"));
这也给我错误。
嗯,是 - 你想一个HashSet的''添加到列表'' - 你有什么期待* *是去做? –
RootObject sample = new HashSet(rootoject.result.Where(item => item.status ==“approved”));这使我有一个错误..我不知道如何得到这个工作.. –
你不能将结果的HashSet添加到RootObject列表,但你可以添加,如果两者都是类型结果 –