派生较多和派生较少的类型

TOP*_*KEK -3 inheritance covariance

假设我们有类层次结构Object<- String<-Username哪个类会派生得更多,哪个派生得少?

如果我声明接口像

interface IValidationRule<in T>
Run Code Online (Sandbox Code Playgroud)

而我的T就是String这是否意味着我将能够使用Username, 但不能使用Object或以其他方式使用?

nvo*_*igt 5

假设Object是基类,从它派生的任何东西(在右边列出)都可以被认为是“更派生的”。

  • 所以“较少派生”意味着在层次结构中上升,而“更多派生”则下降,对吗? (4认同)