开发者

A Class with a generic constrainst while inheriting from another class?

I'm trying determine if it's possible in C# to have a generic class that inherits from another class such as:

public class MySubclass<T> : SomeClass

But this time, I want to put a constraint on T being of some [other] base class like so:

public class My开发者_运维百科Subclass<T> where T : TBaseClass

Is it possible to combine these two? Thanks.


The question is slightly unclear, but I think you want:

public class MySubclass<T> : SomeClass where T : TBaseClass { }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜