Recursive call return a List, return type causing me issues

前端 未结 5 716
遥遥无期
遥遥无期 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:29

    I had the same problem before. Here is the way I solved it:

    public void GetAllChildCategories(ProductCategory ParentCategory)
    {
        ParentCategory.ChildCategories = GetChildCategories(ParentCategory.ID);
    
        foreach(ProductCategory cat in ParentCategory.ChildCategories)
        {
            GetAllChildCategories(cat);
        }
    }
    

提交回复
热议问题