Custom TKey

Discussion in 'ASP .Net' started by Tim Royal, Jun 3, 2008.

  1. Tim Royal

    Tim Royal Guest

    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
    Tim Royal, Jun 3, 2008
    #1
    1. Advertising

  2. Tim Royal

    Munna Guest

    On Jun 3, 6:52 am, "Tim Royal" <> wrote:
    > 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
    Munna, Jun 3, 2008
    #2
    1. Advertising

  3. Tim Royal

    Tim Royal Guest

    FANTASTIC! Thank you very much for the link! It's exactly what I needed.

    Tim

    "Munna" <> wrote in message
    news:...
    > On Jun 3, 6:52 am, "Tim Royal" <> wrote:
    >> 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
    Tim Royal, Jun 3, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer
    Replies:
    1
    Views:
    394
    Axel Dahmen
    Nov 3, 2003
  2. Jonah Olsson
    Replies:
    1
    Views:
    571
    Scott Allen
    Apr 5, 2005
  3. =?Utf-8?B?SW1hciBTcGFhbmphYXJz?=

    Databinding to custom properties of a custom class in ASP.NET 2

    =?Utf-8?B?SW1hciBTcGFhbmphYXJz?=, Apr 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    589
    =?Utf-8?B?SW1hciBTcGFhbmphYXJz?=
    Apr 20, 2005
  4. DKode
    Replies:
    4
    Views:
    583
    DKode
    Nov 7, 2005
  5. =?Utf-8?B?SmF5YnVmZmV0?=
    Replies:
    9
    Views:
    848
    Phillip Williams
    Feb 21, 2006
Loading...

Share This Page