Dictionary<K,V>

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

Hello!

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

//Tony
 
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 IEqualityComparer), and it's generally a bad idea
to use mutable types as keys, but that's it really.

Jon
 
Hello!

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

//Tony

"Kerem Gümrükcü" <[email protected]> skrev i meddelandet




- 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.
 

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

Similar Threads


Back
Top