In C# 4.0, is it possible to derive a class from a generic type parameter?

后端 未结 4 2143
一向
一向 2020-12-06 04:18

I\'ve been trying this, but I can\'t seem to figure this out. I want to do this...

public abstract class SingletonType : TBase         


        
4条回答
  •  长情又很酷
    2020-12-06 04:53

    No, this is not possible. For example, take a type that is declared sealed. You can't inherit from that class, and there is no constraint to limit to non sealed types, ergo trying to inherit from it via a generic parameter is impossible.

提交回复
热议问题