Monday, June 15, 2009

Chapter 4-Lesson 5

  • Generic classes are type-safe compared to usual collections.
  • There exists a generic equivalent to almost all the collections discussed in earlier chapters. e.g. ArrayList as List<>, etc.
  • Generic List<> collection allows an overload of Sort( ) method to supply a generic delegate for comparison.
  • One difference between generic Dictionary<> class and its non-generic counterparts is that it does not use DictionaryEntry objects to hold items, instead it uses generic KeyValuePair.
  • Generic LinkedList<> is new in .NET 2.0. It consists of LinkedListNode objects and uses ILinkedListEnumerator.
  • Using foreach on a LinkedList will not return LinkedListNode type objects. Instead it will return objects of type that is used to store value in each LinkedList node. Explaination code on Page 255 of MS Press book.
  • Generic collections support generic interfaces, generic enumerators and generic comparisons for type-safety.
  • Three classes are common to almost all collections in System.Collections namespace (and any of its sub-namespaces), namely, CollectionBase, ReadOnlyCollectionBase and DictionaryBase.
  • From .NET 2.0 onwards, its preferrable to use generic collections than non-generic ones.

No comments:

Post a Comment