Dictionary<K,V>

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony

    Dictionary<K,V>

    Hello!

    When you are using a Dictionary object what type is to possible to have on
    the key?

    //Tony


  • Kerem Gümrükcü

    #2
    Re: Dictionary&lt;K ,V&gt;

    Hi Toni,
    >When you are using a Dictionary object what type is to possible to have on
    >the key?
    AFIK any!


    Regards

    Kerem

    --
    -----------------------
    Beste Grüsse / Best regards / Votre bien devoue
    Kerem Gümrükcü
    Microsoft Live Space: http://kerem-g.spaces.live.com/
    Latest Open-Source Projects: http://entwicklung.junetz.de
    -----------------------
    "This reply is provided as is, without warranty express or implied."
    "Tony" <johansson.ande rsson@telia.com schrieb im Newsbeitrag
    news:uljieRR0IH A.2384@TK2MSFTN GP02.phx.gbl...
    Hello!
    >
    When you are using a Dictionary object what type is to possible to have on
    the key?
    >
    //Tony
    >
    >

    Comment

    • Jon Skeet [C# MVP]

      #3
      Re: Dictionary&lt;K ,V&gt;

      On Jun 18, 8:31 am, "Tony" <johansson.ande rs...@telia.com wrote:
      When you are using a Dictionary object what type is to possible to have on
      the key?
      Anything. If it's a reference type and doesn't override Equals/
      GetHashCode then you'll only get an identity look-up (unless you
      specify a separate IEqualityCompar er), and it's generally a bad idea
      to use mutable types as keys, but that's it really.

      Jon

      Comment

      • Tony

        #4
        Re: Dictionary&lt;K ,V&gt;

        Hello!

        But how is that done if a class is used as a key?

        //Tony

        "Kerem Gümrükcü" <kareem114@hotm ail.comskrev i meddelandet
        news:OeZqDWR0IH A.4084@TK2MSFTN GP05.phx.gbl...
        Hi Toni,
        >
        When you are using a Dictionary object what type is to possible to have
        on
        the key?
        >
        AFIK any!
        >
        >
        Regards
        >
        Kerem
        >
        --
        -----------------------
        Beste Grüsse / Best regards / Votre bien devoue
        Kerem Gümrükcü
        Microsoft Live Space: http://kerem-g.spaces.live.com/
        Latest Open-Source Projects: http://entwicklung.junetz.de
        -----------------------
        "This reply is provided as is, without warranty express or implied."
        "Tony" <johansson.ande rsson@telia.com schrieb im Newsbeitrag
        news:uljieRR0IH A.2384@TK2MSFTN GP02.phx.gbl...
        Hello!

        When you are using a Dictionary object what type is to possible to have
        on
        the key?

        //Tony
        >
        >

        Comment

        • Jon Skeet [C# MVP]

          #5
          Re: Dictionary&lt;K ,V&gt;

          On Jun 18, 8:44 am, "Tony" <johansson.ande rs...@telia.com wrote:
          But how is that done if a class is used as a key?
          What do you mean? Why would you expect it not to work?

          Jon

          Comment

          • Duggi

            #6
            Re: Dictionary&lt;K ,V&gt;

            On Jun 18, 12:44 pm, "Tony" <johansson.ande rs...@telia.com wrote:
            Hello!
            >
            But how is that done if a class is used as a key?
            >
            //Tony
            >
            "Kerem Gümrükcü" <kareem...@hotm ail.comskrev i meddelandetnews :OeZqDWR0IHA.40 84@TK2MSFTNGP05 .phx.gbl...
            >
            >
            >
            Hi Toni,
            >
            >When you are using a Dictionary object what type is to possible to have
            on
            >the key?
            >
            AFIK any!
            >
            Regards
            >
            Kerem
            >
            --
            -----------------------
            Beste Grüsse / Best regards / Votre bien devoue
            Kerem Gümrükcü
            Microsoft Live Space:http://kerem-g.spaces.live.com/
            Latest Open-Source Projects:http://entwicklung.junetz.de
            -----------------------
            "This reply is provided as is, without warranty express or implied."
            "Tony" <johansson.ande rs...@telia.com schrieb im Newsbeitrag
            news:uljieRR0IH A.2384@TK2MSFTN GP02.phx.gbl...
            Hello!
            >
            When you are using a Dictionary object what type is to possible to have
            on
            the key?
            >
            //Tony- Hide quoted text -
            >
            - Show quoted text -
            Dictionary allows object as key, I think while retrieving the value
            from dictionary, it uses HashCode of the object.

            Anything fishey or you are expecting a BUG in baseclass library?

            -Cnu.

            Comment

            • Registered User

              #7
              Re: Dictionary&lt;K ,V&gt;

              On Wed, 18 Jun 2008 02:57:34 -0700 (PDT), Duggi
              <DuggiSrinivasa Rao@gmail.comwr ote:
              >On Jun 18, 12:44 pm, "Tony" <johansson.ande rs...@telia.com wrote:
              >Hello!
              >>
              >But how is that done if a class is used as a key?
              >>
              Do you mean class as in typeof(someClas s)?

              Comment

              Working...