Custom TKey

T

Tim Royal

On my web site, i have a collection of items that a user could click on. I
originally had a dictionary that kept a key,item list, but now it's grown
more complicated as "new information about what the customer is selling" has
come in.

Long story short, I was looking for a way to have a dictionary use a key
that I defined.

example:

instead of Dictionary<string, object>,

I wanted to have:

Dictionary<customTypeIDefine, object> testDict();

I was able to create a dictionary and add items in by using:

testDict.add(new customTypeIDefine("boo", Style.Left), new
MySpecialObject()),

but it doesn't seem to be able to lookup the values and find them. I'm
guessing it's because somewhere I need to define or implement some
interfaces for the TKey type I've defined.

Is there an article/reference/list of what I need to implement for a TKey to
be usable in this situation?

Thanks for any assistance.

Tim Royal
 
M

Munna

On my web site, i have a collection of items that a user could click on. I
originally had a dictionary that kept a key,item list, but now it's grown
more complicated as "new information about what the customer is selling" has
come in.

Long story short, I was looking for a way to have a dictionary use a key
that I defined.

example:

instead of Dictionary<string, object>,

I wanted to have:

Dictionary<customTypeIDefine, object> testDict();

I was able to create a dictionary and add items in by using:

testDict.add(new customTypeIDefine("boo", Style.Left), new
MySpecialObject()),

but it doesn't seem to be able to lookup the values and find them. I'm
guessing it's because somewhere I need to define or implement some
interfaces for the TKey type I've defined.

Is there an article/reference/list of what I need to implement for a TKey to
be usable in this situation?

Thanks for any assistance.

Tim Royal

Hi

Check out this posts

http://www.codeproject.com/KB/cs/dictionary_customkey.aspx
http://forums.msdn.microsoft.com/en-US/netfxbcl/thread/41fd15a3-6fda-4855-afe5-73498fd1a067/

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top