What is the difference between IEnumerable
and IEnumerable
?
I've seen many framework classes implementing both these interfaces, therefore I would like to know what advantages one get by implementing both?
Please have a look how they've been defined:
public interface IEnumerable
{
[DispId(-4)]
IEnumerator GetEnumerator();
}
public interface IEnumerable<T> : IEnumerable
{
IEnumerator<T> GetEnumerator();
}
As we see, IEnumerable
derives from IEnumerable
, that means whatever IEnumerable
has, IEnumerable
inherits, then why do we implement both instead of just IEnumerable
? Is implementing IEnumerable
not enough?
Likewise, there are other similar pairs:
IList
and IList
ICollection
and ICollection
I would like to know about these as well.