CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2011
    Posts
    5

    Exclamation 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.

  2. #2
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    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.

  3. #3
    Join Date
    May 2007
    Posts
    1,546

    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
  •  





Click Here to Expand Forum to Full Width

Featured