I\'m stuck, why isn\'t this working:
var childAction = new Action(blabla);
Action upperAction = (Action
The type parameter of Action
is contravariant: you can assign an Action
to an Action
because obviously a method that can work on any object can also work on a string.
What you do here is trying to bill a method that works on a CancelCommand
(derived type) as a method that works on any IDomainCommand
(base type). This is logically wrong, so the compiler doesn't let you do it -- if it did, you could just invoke upperAction
passing it a DifferentTypeOfDomainCommand
.