Sunday, February 5, 2012

Cheat sheet for Collections in C#

Tuesday, May 5, 2009, 15:51
This news item was posted in Technology category and has 0 Comments so far.

Lot of times I see myself going back to the books to check which ‘collection’ would be the best suited for a particular activity I am performing in my code. After doing this several times I thougt it would be great to create a cheat-sheet of all the collections and where they can be used efficiently.

 

Now that I have had it for several months, I thought I should share it on the world wide web ! So help yourself -

ArrayList:

Simple, resizeable, index-based collection of objects

 

SortedList:

Sorted collection of name/value pairs of objects

 

Queue:

First In First Out (FIFO) collection of objects

 

Stack:

Last In First Out (LIFO) collection of objects

 

Hashtable:

Collection of name/value pairs of objects that allow retrieval by name or index

 

BitArray:

Compact collection of boolean values

 

StringCollection:

Simple collection of resizeable collection of strings

 

StringDictionary:

Collection of name/value pairs of strings that allow retrieval by name or index

 

ListDictionary:

Efficient collection to store small lists of objects

 

HybridDictionary:

Collection that uses ListDictionary for storage when the number of items in the collection is small, and then migrates the items to a Hashtable for large collection

 

NameValueCollection:

Collection of name/value pairs of strings that allows retrieval by name or index

Responses are currently closed, but you can trackback from your own site.

website design quote