Home > OS >  how to reference the Type in the Concrete class of a generic class
how to reference the Type in the Concrete class of a generic class

Time:01-18

I found the following example, to which I have a follow up question.

enter image description here

and if there is shared logic between all of concrete classes you can put it in the abstract class and override abstract protected methods instead.

CodePudding user response:

But what is wrong with this

public class BarRepository<T> : Repository<Bar> where T : class
{
    public override void Update(Bar item)
    {

    }
    
    public  void Update(T item)
    {
     
    }
}
  •  Tags:  
  • Related