Intro_Collections.htm ( Under consruction)
C# Ref :
  • System.Collections Namespaces
    • System.Collections
    • System.Collections.Concurrent
    • System.Collections.Generic
    • System.Collections.ObjectModel
    • System.Collections.Specialized
System.Collections Namespace
The System.Collections namespace contains many interfaces and classes that define various collections of objects, such as lists, queues, bit arrays, hash tables and dictionaries.
Collections: When groupings of data or results are crucial, we need collections. Groupings can be done either of of these following ways.
  • Creating Arrays oh objects : remains a static body
  • Creating Collection of Objects : stretches dynamically and expandable.
    • Key to a set of Data is a choice with Collections.
    • Collection with single data type : use System.Collection.Generic  namespace.
      • Generic collection enforces safety, and no other data types can be added to the collection. No data conversion is needed.
 System.Collections Categories:
  • System.Collections :  Use these classes with the Generic or Concurrent  namespaces. 
    • ArrayList, Hashtable, Stack, and Queue.
  • System.CollectionsGeneric : To work with a strongly typed list of objects. This type of  collection enforces strong typing  with desired data type, and allowing only the desired data type to be added.  Types are :
    • Dictionary<TKey, TValue>, List<T>, Queue<T>, SortedList<TKey, TValue>, and Stack<T>
  • Concurrent : For Threadsafe and multiple thread operation, this namespace should be used ( in the place other two options).
System.Collections Classes
  • ArrayList : It is a non-generic version of Generic-List<T>.
    Implements the IList dynamic interface using an array whose size dynamically expands to pace with  future growth
    • constructors
      • ArrayList(), ArrayList(ICollection), ArrayList(Int32)
    • methods ; Adapter, Add, AddRange
  • Hashtable : Key/Value pair.
  • Queue: FIFO
  • Stack : LIFO

Note : To distinguish ArrayList from Hashtable, ArrayList stores only value, where as Hashtable stores data as key/value. To pass ArrayList , you need value and to pass hashtable you need to pass name.

 System.Collections.Generic Few Important members
  • Generic Classes :
  • Comparer<T>
  • Dictionary<Tkey, TValue>: based on key.
  • List<T> : accessed by Index
    It is generic version of ArrayList
  • Queue<T> : FIFO
  • SortedList<Tkey, TValue> : key based sorting
  • Stack<T> : LIFO
  • BitArray
    Manages a compact array of bit values, as bit is on (1) for true  and  bit is off (0) for false.
    • Constructors: BitArray, Boolean[], Byte[], Int32, Int32[], Int32, Boolean.
    • methods: And, Clone, ICollection, CopyTo, Get, No, Or, Set, SetAll
    • Properties: count, IsReadOnly, IsSynchronized,
    • Item, Length, SyncRoot


  • CaseInsensitiveComparer
    Compares two objects for equivalence, ignoring the case of strings.
  • Others : Members (Structures, classes and Interfaces) of (Non Generic) System .Collections Namespace
  • CaseInsensitiveHashCodeProvider
    Supplies a hash code for an object, using a hashing algorithm that ignores the case of strings.
  • CollectionBase Class
    Provides the abstract base class for a strongly typed collection.
  • Comparer Class
    Compares two objects for equivalence, where string comparisons are case-sensitive.
  • DictionaryBase Class
    Provides the abstract base class for a strongly typed collection of key/value pairs.
  • Hashtable Class
    A hastable store data as a pair of name/value. Represents a :  collection of key/value pairs that are organized based on the hash code of the key.
  • Queue Class
    Represents a first-in, first-out collection of objects.
  • ReadOnlyCollectionBase Class
    Provides the abstract base class for a strongly typed non-generic read-only collection.
  • SortedList Class
    Represents a collection of key/value pairs that are sorted by the keys and are accessible by key and by index.
  • Stack Class
    Represents a simple last-in-first-out (LIFO) non-generic collection of objects.
  • Interfaces
    Interface Description
    • ICollection
      Defines size, enumerators, and synchronization methods for all nongeneric collections.
    • IComparer
      Exposes a method that compares two objects.
    • IDictionary
      Represents a nongeneric collection of key/value pairs.
    • IDictionaryEnumerator
      Enumerates the elements of a nongeneric dictionary.
    • IEnumerable
      Exposes the enumerator, which supports a simple iteration over a non-generic collection.
    • IEnumerator
      Supports a simple iteration over a nongeneric collection.
    • IEqualityComparer
      Defines methods to support the comparison of objects for equality.
    • IHashCodeProvider
      Supplies a hash code for an object, using a custom hash function.
    • IList
      Represents a non-generic collection of objects that can be individually accessed by index.
      Structure Description