I would like to implement an IEqualityComparer<A>
where A
is a superclass of B
, C
and D
. Then I would like to use the same equality comparer to compare lists of objects of classes B
, C
and D
.
However, this does not seem to be possible. The compiler complains that IEqualityComparer<A>
cannot be converted to IEqualityComparer<B>
.
I solved the problem using generic classes. However, this seems somewhat overly complicated. Is there a simple way of achieving this elegantly (like some kind of an implicit cast)?
Aucun commentaire:
Enregistrer un commentaire