C# inheritance in generics question

后端 未结 3 946
清歌不尽
清歌不尽 2021-01-18 03:14

I have two interfaces:

public interface A { 
 void aMethod(); 
}


public interface B : A {
 void bMethod();
} 

Later I\'m basically using

3条回答
  •  温柔的废话
    2021-01-18 03:45

    The feature you are looking for is what's referred to as generics variance (covariance and contravariance). There is limited support for this starting in .net framework 4. Here's an interesting post: How is Generic Covariance & Contra-variance Implemented in C# 4.0?

    And here's the MSDN entry on Covariance and Contravariance in Generics.

提交回复
热议问题