Best way to refer to my own type

前端 未结 5 1951
轻奢々
轻奢々 2021-01-03 06:02
abstract class A where T:A
{
    public event Action Event1;
}

class B : A
{
    //has a field called Action Event1;
}
         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-03 06:30

    I don't think you need to specify where T:A.

    T will be B when you use class B:A

    This is also known as CRTP or Curiously recurring template pattern and is a known idiom.

提交回复
热议问题