Solved

When and why to use IDictionary

Posted on 2006-06-24
3
410 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

867 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now