我想问一下,我可以直接访问嵌套列表类中的值而无需循环吗? 下面的代码是可行的,但我想简化它并可以直接访问该值。非常感谢。
RootObject myjsondata = new RootObject();
RootObject jarray = JsonConvert.DeserializeObject<RootObject>(html);
if(jarray.items.Count>0)
{
foreach (var a in jarray.items)
{
string b = a.snippet.title;
}
}
public class Snippet
{
public string title { get; set; }
}
public class Item
{
public Snippet snippet { get; set; }
}
public class RootObject
{
public List<Item> items { get; set; }
}