0
Is it possible to make two instances of two different classes which are inherited by one interface.
Is it possible to make two instances of two different classes which are inherited by one interface. And make assignment of one instance to another in some good way?
2 Answers
0
If there is an interface `I`, and classes A and B inherit from I, then you can assign either of A or B to a variable of type `I`. So if you assign an instance of A to a variable of type I, then you can assign B to the same variable also.
I don't know much C#, apologize in advance if the following code uses bad practises and I would be happy to be corrected by someone. But this demonstrates what I said above
https://code.sololearn.com/cXS6S7R0WNE1/?ref=app
0
Well yeah that works. Thank you