c# - How to do Recursice Funciton Return List<>? -


i trying playlist on youtube , using json http request. youtube playlist api supports max 50 results want make recursive funciton , funciton should return list.

    private async task<list<classes.playlist>> getplaylist(string id, string pagetoken = null)     {         string jsontext = await x.getjson(id, pagetoken);         list<classes.playlist> list = new list<classes.playlist>();         if (jsontext == null)         {             return null;         }         else         {             jobject jsonobj = jobject.parse(jsontext);             foreach (var item in jsonobj["items"])             {                 list.add(new classes.playlist                 {                     image = (string)item["snippet"]["thumbnails"]["default"]["url"],                     title = (string)item["snippet"]["title"],                     videoid = (string)item["snippet"]["resourceid"]["videoid"]                  });             }             if ((string)jsonobj["nextpagetoken"] != null)             {                 pagetoken = (string)jsonobj["nextpagetoken"];                 list = await getplaylist(id, pagetoken);                 return list;             }             else             { return list; }          } 


Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -