Data structure for category

前端 未结 2 2006
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-16 04:27

I am looking for a data structure to add, remove, get, and find on categories.

For example:

Books

  • Drama
  • Science fic
2条回答
  •  深忆病人
    2021-01-16 05:16

    You can just create a Category class that exposes a list of other Category instances.

    public class Category
    {
        public Category()
        {
            this.ChildCategories = new List();
        }
    
        public string Name { get; set; }
    
        public IList ChildCategories { get; private set; }
    }
    

提交回复
热议问题