Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

When and why to use IDictionary

Posted on 2006-06-24
3
Medium Priority
?
428 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
[X]
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
3 Comments
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 800 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 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Screencast - Getting to Know the Pipeline

598 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