I see stuff like this a lot:
interface A { ... }
interface B : A { ... }
class C : B, A { ...}
Why would you specify that C implements interface A, when B already inherits A? Does it make any semantic difference or is it just a matter of style?
(One of many examples is List<T>
implementing IList<T>
and ICollection<T>
, while IList<T>
also derives from ICollection<T>
).
Update: Thanks for confirming my guess that it doesn't make any semantic difference.
I have come up with a related situation where it does make a difference to explicitly name an interface that is already in the inheritance tree:
If B
were a class, C
would only (re-)implement interface members from A
if it names A
explicitly after the ':
'.
[EDIT] I changed the wording of the question to avoid confusion with explicitly implemented interface members, which restrict the use of the member to cases where the object is cast as the interface.