Enumerators vs. Dictionary
What would be the difference using an Enumerator vs. a Dictionary in C#?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Dave131 reputationPosted May 13, 2008, 10:57 PM EDT
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.
Bechir BejaouiRank #144 · 15.9K reputationPosted May 27, 2008, 1:57 PM EDT