Been a while since
I did a Q&A from internal discussion… Here goes, this one recently
went over the CLR Performance alias.
We were planning to use Hashtable in
one of our projects but before we do that we had a question is that whether it
is efficient enough (in terms of performance and memory usage) to use the
Hashtable class when the number of items in the hashtable may range from
100-200. For our Hashtable both the key and the value are going to be string
Dev lead on the BCL team (who is also giving .NET
Framework: Tips and Tricks for Building Managed Components at the PDC)
Hashtable should be very effective
with this range of items. The lookup should be approximately constant time.
Hashtable has reasonable memory
overhead. If you care more about memory overhead than lookup speed, you can use
SortedList, which uses less memory but has O(LogN) looksups compared to O(1) for