Solved

When and why to use IDictionary

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

690 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