c# - Value from class is unreachable? -
in app i'm using web request pull json data web source , deserializing class. want pull specific value data, i'm finding can't reach current code.
here classes
public class result { public int id { get; set; } public string name { get; set; } public int tracknumber { get; set; } public string title { get; set; } public list<artist> artists { get; set; } public list<genre> genres { get; set; } public release release { get; set; } public label label { get; set; } public images images { get; set; } public int downloadid { get; set; } public string downloadurl { get; set; } // value i'm trying retrieve } public class rootobject { public metadata metadata { get; set; } public observablecollection<result> results { get; set; } }
and code deserialize data attempt store desired value string variable
rootobject data = jsonconvert.deserializeobject<rootobject>(response); string downloadurl = data.results.downloadurl; // downloadurl unreachable
is there better way value need? help.
results collection. try that
string downloadurl = data.results[0].downloadurl;
it give downloadurl first item collection.
Comments
Post a Comment