I know exactly the same question appears here on StackOverflow, nevertheless it does not quite answer my query.
If ICollection<T> implements IEnumerable<T>, which extends IEnumerable, why did programmers from Microsoft add IEnumerable as an interface that the ICollection<T> implements?
Isn’t it exactly (semantically and implementation wise) the same as simply writing ICollection<T> : IEnumerable<T>?
It says it implements
IEnumerablebecause it implementsIEnumerable.IEnumerable<T>inheritsIEnumerable, but it can obviously provide no implementation. Classes that implementIEnumerable<T>must also implementIEnumerable, whether or not they explicitly state that they do so.With either case, you implement the members of both interfaces. The second class definition simply makes it obvious for those looking at the class and/or the documentation, which is a good thing. An inexperienced or otherwise uninformed reader might not know that
IEnumerable<T>bringsIEnumerablealong with it. They might might not know that a class that implementsIEnumerable<T>can be used where anIEnumerableis expected. This simply provides a bit more information to the reader, which can only be a good thing on average.