How Dictionary<TKey,TValue> is checking keys?

  • Thread starter Thread starter Shimon Sim
  • Start date Start date
S

Shimon Sim

I have Dictionary that has custom class as its key. For that class I
implemented both Equals(object) and IComparable<T>. I keep getting
KeyNotFoudException.
What should I do?
Thanks
Shimon
 
You should implement GetHashCode() by overriding this method from
System.Object in your class used as key.
 

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

Back
Top