none
Recursive Fonksiyonda List<>'i return etmek ? RRS feed

  • Soru


  •     

            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; }
    
                }


    OMANSAK



    • Düzenleyen OMANSAK 12 Kasım 2016 Cumartesi 22:48
    12 Kasım 2016 Cumartesi 22:40

Yanıtlar