Click to See Complete Forum and Search --> : Collection


rhr
February 22nd, 2006, 03:14 PM
Which collection class supports a KEY - VALUE colleciton where in VALUE we can store an OBJECT?

Thanks.

Shuja Ali
February 22nd, 2006, 03:41 PM
Which collection class supports a KEY - VALUE colleciton where in VALUE we can store an OBJECT?

Thanks.
System.Collections.Hashtable class will allow you create a collection containing KEY-Value pair for Objects.

rhr
February 22nd, 2006, 04:03 PM
Thanks for the reply Shuja.

I was just looking at Generics and found the following:

Dictionary<string, object> MenuCollectionObj = new Dictionary<string, object>();

In real world, which would be a better practice? Generics or HashTable?

Shuja Ali
February 22nd, 2006, 04:11 PM
Although I have not used C# 2.0 yet, but I would think that Generics will be better because they give you the freedom of defining type-safe data structures without actually committing to the actual data types that you will be using. You should wait for a reply from someone who has been using C# 2.0.

And yes when you are asking questions about .NET 2.0 you will have to mention it in the thread title or in your first post.