F
F
fastec2013-12-12 06:22:42
User interface
fastec, 2013-12-12 06:22:42

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

1 answer(s)
I
Ilya Evseev, 2013-12-12
@fastec

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 question

Ask a Question

731 491 924 answers to any question