# .NET Development Foundation/Using collections
## Using Collections

Exam objective: Manage a group of associated data in a .NET Framework application by using collections.
(Refer System.Collections namespace - MSDN)

##### ArrayList class

see MSDN
The ArrayList class is used for arrays whose size will dynamically increase as required. An ArrayList is not necessarily sorted.

##### Collection interfaces

    ICollection interface and IList interface
       ICollection interface - MSDN
          The ICollection interface is the base interface for classes in the System.Collections namespace.
          The ICollection interface extends IEnumerable; IDictionary and IList are more specialized interfaces that extend ICollection. An IDictionary implementation is a collection of key/value pairs, like the Hashtable class. An IList implementation is a collection of values and its members can be accessed by index, like the ArrayList class.
          Some collections that limit access to their elements, such as the Queue class and the Stack class, directly implement the ICollection interface.
          If neither the IDictionary interface nor the IList interface meet the requirements of the required collection, derive the new collection class from the ICollection interface instead for more flexibility.
          The following tables list the members exposed by the ICollection type.
          Public Properties
          Public Methods
       IList interface - MSDN
    IComparer interface, IEqualityComparer interface, and IKeyComparer interface
       IComparer interface - MSDN
       IEqualityComparer interface - MSDN
       IKeyComparer interface - IKeyComparer does not exist in .Net 2.0
    IDictionary interface and IDictionaryEnumerator interface
       IDictionary interface - MSDN
       IDictionaryEnumerator interface - MSDN
    IEnumerable interface and IEnumerator interface - MSDN and MSDN
IEnumerator sample
Write down a handler for Practicing the above code.
* One way of using IEnumerator.
* One way of using IEnumerable.
    IHashCodeProvider interface - MSDN - Interface is now obsolete (as of .NET 2.0)

### Iterators

See MSDN
    An iterator is effectively a lightweight version of the IEnumerable interface. It is primarily used with foreach statements.
    You will normally implement the GetEnumerator method of the IEnumerable interface.
    This enables the class to be accessed using a standard foreach statement. A class is not restricted to implementing only a single iterator. Multiple iterators can be supplied, for example to enable iteration in both ascending and descending order of a list. To call a named iterator, use the following syntax:
    The yield statement marks a point where execution of a iterator will resume on a subsequent iteration. This can be used to supply multiple yield statements:
    To end the iteration programmatically, use the
    statement.
Hashtable class - MSDN
    Used to represent a collection of key/value pairs.
CollectionBase class and ReadOnlyCollectionBase class
    CollectionBase class - MSDN
    ReadOnlyCollectionBase class -MSDN
DictionaryBase class and DictionaryEntry class
    DictionaryBase class - MSDN
    DictionaryEntry structure - MSDN
Comparer class - MSDN
Queue class - MSDN
SortedList class - MSDN
BitArray class - MSDN
Stack class - MSDN
<noinclide>