Using generics in abstract classes

前端 未结 7 1526
眼角桃花
眼角桃花 2020-12-05 10:17

I\'m working on an abstract class where the implementing class needs to implement a list of T. The problem is that this doesn\'t work:

public class AbstractC         


        
7条回答
  •  爱一瞬间的悲伤
    2020-12-05 10:54

    You need to define T like so

    public class AbstractClass
    {
        public int Id { get; set; }
        public int Name { get; set; }
    
        public abstract List Items { get; set; }
    }
    
    public class Container : AbstractClass
    {
        public List Items { get; set; }
    }
    

提交回复
热议问题