Recursive call return a List, return type causing me issues

前端 未结 5 715
遥遥无期
遥遥无期 2021-02-04 06:12

I have a recursive method that is return me categories, and checking for its sub categories.

So it looks like:

public List GetAllChildCat         


        
5条回答
  •  生来不讨喜
    2021-02-04 06:26

       foreach(Category cat in c.ChildCategories)
          {
                  list.AddRange( GetAllChildCats(cat.CategoryID) )
    
          }
    

    and don't forget the

    return list;
    

提交回复
热议问题