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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -