Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

When and why to use IDictionary

Posted on 2006-06-24
3
416 Views
Last Modified: 2010-05-19
There are many collection classes and generic collection classes.  When do I use IDictionary versus hashtable which also takes a key?

Any "tomes" on this work - when to use what collection?
0
Comment
Question by:vamail2
3 Comments
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 200 total points
ID: 16976822
Hi...

Take a look at this link:
http://msdn2.microsoft.com/en-us/library/system.collections.hashtable.aspx

Notice the HashTable object signatura:

[SerializableAttribute]
[ComVisibleAttribute(true)]
public class Hashtable : IDictionary, ICollection, IEnumerable,
    ISerializable, IDeserializationCallback, ICloneable

You can see that HashTable actually implements IDictionary!! :)

IDictionary just represents a nongeneric collection of key/value pairs, as you can also read from http://msdn2.microsoft.com/en-us/library/system.collections.idictionary.aspx.
There are more collection objects the implement it... actually all that manage items as a Key/value.

To finish... IDictionary is an interface, you don't actually use it comparativelly to the HashTable class.
You can use IDictionary if you want to create your own custom collection if inheriting from an existing implementation doesn't fit you needs.

Alex :p
0
 
LVL 7

Assisted Solution

by:pradeepsudharsan
pradeepsudharsan earned 50 total points
ID: 16977422
IDictionary is an interface which is used to retrive the key,value pairs from the Hash Table in the order in which you are entered the key,value pairs into the hash table.(First in First Out)

If you use other methods to retrive the key,value pairs from the Hash Table,
they will give you the wrong ordering of results.
0
 

Author Comment

by:vamail2
ID: 16979080
Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reading the Web.Config using IIS 7.5? 4 47
VB.NET (2008) - Refactoring Question 2 23
insert value of checklistbox checked 4 32
Change to file doesn't show up 16 51
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question