Are enum types faster/more efficient than string types when used as dictionary keys?
IDictionary or IDict
Certainly the enum
version is better (when both are applicable and make sense, of course). Not just for performance (it can be better or worse, see Rashack's very good comment) as it's checked compile time and results in cleaner code.
You can circumvent the comparer issue by using Dictionary
and casting enum
keys to int
s or specifying a custom comparer.