开发者

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

开发者 https://www.devze.com 2023-02-18 20:28 出处:网络
I\'m trying determine if it\'s possible in C# to have a generic class that inherits from another class such as:

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

精彩评论

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