Answer the question
In order to leave comments, you need to log in
A couple of stupid questions about polymorphism and inheritance?
Why do you need to write , and not like that ? I understand what the interface is for in a general sense, but I don’t understand why it should be used in this particular situation.
What happens in this situation ? And how is it different from ? IList list = new List()
List list = new List()
Base A = new Derived()
Derived B = new Derived()
Answer the question
In order to leave comments, you need to log in
Reduces the chance of mistakenly accessing List and Derived fields and methods not listed in IList and Base.
That is, there is not a mandatory rule here, but a recommendation to reduce potential problems - hide the object from your crooked hands behind the minimum sufficient interface.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question