C# Collections: A Detailed Presentation

ISBN: 9781932504095

C# Collections: A Detailed Presentation dives deep into the operations of the .NET Collections framework. It begins by demonstrating how the .NET Collections framework can save you a lot of time and effort by giving you tons of proven functionality. For most situations you’ll encounter, there’s usually no need to roll your own custom data structure. It then presents an overview of the fundamental data structures:  arrays, linked-lists, hash tables, stacks, queues, and trees and demonstrates how the functionality of each of the fundamental data structures is implemented by one or more corresponding collection classes. The book continues by demonstrating how to combine collections with multi-threaded programming techniques. Event processing and events on collections is covered in detail as well.

Source Code: CollectionBookProjects.zip

Material covered includes:

  • Explanation of collection framework inheritance hierarchy
  • Explanation of the differences between collection types and the performance characteristics of their underlying data structures
  • Clearly explained code examples showing implementation of stacks, ring buffers, queues, doubly-linked circular list, and red-black trees
  • How to properly implement important collection-related interfaces including IEnumerable, IEnumerable<T>, IComparable, IComparable<T>, IDictionary<KeyValuePair<TKey, TValue>>, etc.
  • The use of generics to create custom generic classes.
  • Explanation and demonstration of generic constraints including the default constructor constraint, reference type constraint, value type constraint, inheritance constraint, and naked constraint
  • Detailed explanations of single- and multidimensional arrays
  • How to use the Array class to sort and manipulate arrays
  • How to implement natural ordering in user-defined data types by implementing the IComparable and IComparable<T> interfaces
  • How to implement custom ordering for user-defined data types via custom comparers
  • How to implement custom XML serialization for complex user-defined collections
  • How to allow a custom collection to be iterated with a foreach statement
  • How to implement named iterators for custom ordering
  • How to implement the Weak Event Listener pattern
  • How to implement one-way data bindings between collections and GUI components
  • How to implement two-way data bindings between collections and GUI components
  • How to implement the ICollectionChanged and IPropertyChanged interfaces
  • How to respond to CollectionChanged and PropertyChanged events
  • Detailed treatment of threading and how to create threadsafe collections
  • How to use the lock keyword to coordinate multithread access to code segments
  • How to persist collections to disk or send collections over the network
  • …and much, much more