Collection interfaces
As the name implies, a collection interface is an interface that provides the contract for a specific collection.
The .NET Framework provides a number of standard collection interfaces:
- ICollection - Implemented by all collections
- IList - Used by collections that can be indexed
- IDictionary - For key/value-based collections such as Hashtable and SortedList
- IComparer - Allows custom comparison for purpose of sorting and ordering
- IEqualityComparer - Allows custom equality comparisons for collections that depend on equality but not order (like Hashtable)
- IKeyComparer - Replaced by
IEqualityComparersince .NET 2.0 beta 2 - IHashCodeProvider - Replaced by
IEqualityComparersince .NET 2.0 beta 2
- IEnumerable - Provides the Enumerator for a collection
- IEnumerator - Iterates over a collection and supports the foreach loop
- IDictionaryEnumerator - An enumerator that enumerates a dictionary and add support for accessing the key and value of the current item.
Contents |
ICollection
ICollection extends IEnumerable. It provides size and synchronization members in addition to enumeration.
IList
IList extends ICollection. It allows access to the items of a collection by their index.
IDictionary
IDictionary extends ICollection. It allows access to the items of a collection by their key.
IComparer
Allows custom comparison for the purposes of sorting and ordering.
IEqualityComparer
Allows custom equality comparisons for collections that depend on equality but not order (like Hashtable)
IKeyComparer
Replaced by IEqualityComparer since .NET 2.0 beta 2
IHashCodeProvider
Replaced by IEqualityComparer since .NET 2.0 beta 2
IEnumerable
IEnumerable allows a class to be enumerated using an enumerator. A class should inherit from IEnumerable in order to provide an enumerator through the GetEnumerator() method.
The foreach automatically calls GetEnumerator at the beginning of the loop and then uses that enumerator to go through the loop.
IEnumerator
An IEnumerator iterates over each item in a collection. It allows access to the current item and the ability to proceed to the next item. The foreach loop uses an enumerator to go through each item.
IDictionaryEnumerator
A IDictionaryEnumerator extends IEnumerator. It also adds support for accessing the key and value of the current item.
|

