I do not think this is possible in this particular case. If both classes return object types, you will have some chance, but since you are mixing base and object types, there is no compatible type that supports both interfaces.
Another approach may be to implement appropriate interfaces that are compatible, and then use composition to preserve the internal structure and calls of the map function, if necessary. This assumes that you do not need to be satisfied or suitable for use as both interfaces, but rather that you need to expose.
However, if you need to make this class interchangeable as two incompatible interfaces, this cannot be done.
user1676075
source share