Let's examine an example:
Consider, for instance, the
IEnumerable[
^] interface. It specifies the
contract your
custom collection must fulfil in in order to support the
foreach
semantics.
Now,
foreach
knows nothing about your custom collection (but the fact that it fulfils the
IEnumerable
interface). Moreover, you're free to implement all the details of your collection (probably, it wouldn't make sense inheriting a 'piece of code' from
IEnumerable
).
:)