IList and List Conversions with Interfaces

后端 未结 6 1637
攒了一身酷
攒了一身酷 2021-01-03 01:06

I generally understand interfaces, inheritance and polymorphism, but one thing has me puzzled.

In this example, Cat implements IAnimal

6条回答
  •  猫巷女王i
    2021-01-03 01:36

    This type of covariance is not supported in C# 4.0. It is reasonable to expect the behavior you want, it just isn't supported (for now).

提交回复
热议问题