Saturday, March 5, 2011

After reading http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx
I will rewrite all my methods to use a List instead of an ArrayList.

Difference between List, HashTable and Dictionary

According to http://msdn.microsoft.com/en-us/library/ms379571(v=vs.80).aspx, a Hash table is the fastest data structure in C# when you know the number of records you are going to store because of the collision resulution method.

The better performance of a Hshtable over a Dictionary is doubtful however, due to boxing/unboxing which occurs when using a HashTable (http://msdn.microsoft.com/en-us/library/4yh14awz(v=vs.80).aspx).

Some sources say that HastTable is simply used for backward compability, and the new programs should always use a Dictionary.

My approach will be to use a Dictionary when I have to search for records and a List when I simply add new records or process records one by one. I will be curious to test the performance of a HastTable over a Dictionary though for a fixed-size array.
A good article about how to improve the performance of a DataReader:


http://sqlblog.com/blogs/adam_machanic/archive/2006/07/12/sqldatareader-performance-tips.aspx