Enumerators vs. Dictionary
What would be the difference using an Enumerator vs. a Dictionary in C#?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Bechir BejaouiPosted May 27, 2008, 5:57 PM
DavePosted May 14, 2008, 2:57 AM
I will give you my thoughts on the issue. Firstly, by Enumerator, I am guessing you mean the primitive enum type. If you actually mean Enumerators in the enumerating over a collection sense, then my answer would differ.
The big difference between dictionary and enum is that enum is a primitive type which is very simple to create, declare and work with. When talking about Dictionary, there is no actual Dictionary type. However, there are classes which implement the IDictionary interface. For example, the HashTable implements IDictionary, as it is a nongeneric collection of key/value pairs. SortedList also implements IDictionary.
So basically, if you need to create a collection which uses key/value pairs, implementing IDictionary would be the way to go. However, if you just want a quick and dirty enumerated list which provides a finite list of options to choose from, the enum is more appropriate.