Custom TKey

  • Thread starter Thread starter Tim Royal
  • Start date Start date
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
 
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
 
Back
Top