Question

In this post, a SO user offers an alternative to Dictionary (the HashTable implementation in C#).

What are the advantages and disadvantages of this approach?

Would performance be a disadvantage? His approach seems to iterate through all the classes to find the correct object but a HashTable would immediately find the value based on the hash function of the key, right?

Was it helpful?

Solution

A Dictionary requires unique keys, which might be an issue in some cases. Obviously the class provides encapsulation, which is always good, but the Dictionary provides more efficient lookup. It's quite possible to use both though. You use the Dictionary for fast lookup and then the value you get is a class that encapsulates all the related data for the entity, which would probably include the key as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top