|
-
February 6th, 2012, 05:29 PM
#1
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.
-
February 7th, 2012, 01:35 AM
#2
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.
Best Regards,
BioPhysEngr
http://blog.biophysengr.net
--
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
-
February 7th, 2012, 06:28 AM
#3
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>
www.monotorrent.com For all your .NET bittorrent needs
NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|