Difference between Dictionary and OrderedDictionary??
Can anyone explain the difference between these two classes:
Dictionary: http://msdn.microsoft.com/en-us/library/xfhwa508.aspx
OrderedDictionary : http://msdn.microsoft.com/en-us/libr...ictionary.aspx
I can't seem to identify which one to use.
thanks.
Re: Difference between Dictionary and OrderedDictionary??
Dictionary is type safe using generics. OrderedDictionary accepts any object generally (stores all items at object and requires casts when accessing data). You (almost certainly) want to use Dictionary.
Re: Difference between Dictionary and OrderedDictionary??
The biggest difference is that OrderedDictionary can be used like a regular dictionary and also as if it were a List. You can access items by index and they are stored in the order in which you added them.
If you require both semantics, then maybe making a generic version of OrderedDictionary would be good to have. Otherwise, just use a regular List<T> or a Dictionary<K, V>