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

Exam objective: Improve type safety and application performance in a .NET Framework application by using generic collections.
(Refer System.Collections.Generic namespace MSDN )

### Collection.Generic interfaces

    Generic IComparable interface - MSDN
       Note that IComparable<T> is a member of the System namespace.
       You use this interface when you create a class and you want it to be used with generic types that support ordering (ex. SortedList<T> or List<T>.Sort) without having to specify a comparer object. The only method of IComparable<T> is CompareTo<T>(T other). There is an example on MSDN.
       The following example implements IComparable<T> for a custom made Point class. The example uses a List<T> instead of a SortedList<T> or OrderedDictionnary<T> because the comparaison is done based on the distance of the points from the origin which can give the same value for many points.
Simple use IComparable<T> (C#)
    Generic ICollection interface and Generic IList interface
       Generic ICollection interface - MSDN
       Generic IList interface - MSDN
    Generic IComparer interface and Generic IEqualityComparer interface
       Generic IComparer interface - MSDN
       Generic IEqualityComparer interface - MSDN
    Generic IDictionary interface - MSDN
    Generic IEnumerable interface and Generic IEnumerator interface
       Generic IEnumerable interface - MSDN
          see also ONDotnet
       Generic IEnumerator interface - MSDN
       IHashCodeProvider interface - MSDN - Interface is now obsolete (as of .NET 2.0)

##### Generic Dictionary

    Generic Dictionary class and Generic Dictionary.Enumerator structure
       Generic Dictionary class - MSDN
       Generic Dictionary.Enumerator structure - MSDN
    Generic Dictionary.KeyCollection class and Dictionary.KeyCollection.Enumerator structure
       Generic Dictionary.KeyCollection class - MSDN
       Dictionary.KeyCollection.Enumerator structure - MSDN
    Generic Dictionary.ValueCollection class and Dictionary.ValueCollection.Enumerator structure
       Generic Dictionary.ValueCollection class - MSDN
       Dictionary.ValueCollection.Enumerator structure - MSDN

### Generic Comparer class and Generic EqualityComparer class

    Generic Comparer class - MSDN
       The Comparer<T> class serves as a base class to easily implement the IComparer<T> interface.
       The example is the same then for the IComparable<T> except that now a Comparer<T> derived object is given to the List<T>.Sort method instead of implementing the IComparable<T> interface on Point.
       This way of preceding has 2 advantages:
      * It can be used even if you dont have access to the source code of Point
      * You can have more than one Comparer derived class for the same Point class
Custom Comparer<T> (C#)
    Generic EqualityComparer class - MSDN

### Generic KeyValuePair structure

    see MSDN

### Generic List class, Generic List.Enumerator structure, and Generic SortedList class

    Generic List class - MSDN
       A generic list class instance is simply declared using the List<T> syntax where T is the specific type.
    Generic List.Enumerator structure - MSDN
    Generic SortedList class - MSDN

### Generic Queue class and Generic Queue.Enumerator structure

    Generic Queue class - MSDN
    Generic Queue.Enumerator structure - MSDN

### Generic SortedDictionary class

    See MSDN
    For differences between SortedList and SortedDictionary are explained see MSDN

### Generic LinkedList

    A Generic Linked List represents a doubly linked list and is a general-purpose linked list. It supports enumerators and implements the ICollection interface, consistent with other classes in the .NET Framework.
    Generic LinkedList class - MSDN
    Generic LinkedList.Enumerator structure - MSDN
    Generic LinkedListNode class - MSDN

### Generic Stack class and Generic Stack.Enumerator structure

    Generic Stack class - MSDN
    Generic Stack.Enumerator structure - MSDN