Print This Post
27
Jul/09
0

When to use a Dictionary (Hashtable)?

Here’s a pretty good tutorial on hashtable / dictionaries. Found it while studying some performance issues between the use of try/catch vs contains key for a dictionary with about 200,000 key/value associations.

A Dictionary is closely related to a HashTable. There are many subtle differences between them, but one important difference is that a Dictionary is generally faster than a Hashtable for storing data.

The reason is that a Dictionary takes strongly-typed values as its input, so you do not suffer the performance impact of storing generic Objects and boxing/unboxing them into the proper types during use.

http://www.kirupa.com/net/dictionary_hashtable.htm

Filed under: C#
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

You must be logged in to post a comment.

No trackbacks yet.

Copy Protected by Chetan's WP-CopyProtect.