Labels

Tuesday, March 31, 2009

Collection Choice Myth

Hi,

 

Below are the supported List & Collection Types.

 

 

ArrayList

This is a dynamically sizable array. It is useful when you do not know the required array size at design time.

 

StringCollection

This is a strongly typed Array List for strings.

 

Queue

This is a first-in, first-out collection that implements ICollection.

 

Stack

This is a simple last-in, first-out collection of objects.

 

 

 

Hashtable

This is a collection of key/value pairs that are organized based on the hash code of the key. It is appropriate when you need to search but not sort.

 

StringDictionary

This is a hash table with the key strongly typed to be a string rather than an object.

 

SortedList

This is a collection of key/value pairs that are sorted by the keys and are accessible by key and by index. Appropriate when Sorting is the need.

 

 

NameValueCollection

This is a sorted collection of associated String keys and String values that can be accessed either with the key or with the index.

 

ListDictionary

This is useful for storing 10 or less key/value pairs.

 

HybridDictionary

This uses a ListDictionary when the collection is small, and switches to Hashtable when the collection gets large.

 

 

Among the various below is the choices one should go for.

 

  • ArrayList / StringCollection
  • Queue
  • Stack

 

 

  • HashTable / StringDictionary
  • SortedList / NameValueCollection
  • ListDictionary
  • HybridDictionary – List Dictinaory -> HashTable

 

 

Regards,

Arun Manglick

No comments:

Post a Comment