KeyNotFoundException in filled dictionary

后端 未结 2 1992

I am trying to modify value in dictionary, but the compiler throws KeyNotFoundException. I\'m sure, I declared that key in dictionary, because I am calling

相关标签:
2条回答
  • 2020-12-21 12:10

    Yes. You have not overridden GetHashCode.

    0 讨论(0)
  • 2020-12-21 12:18

    Dictionary is using the GetHashCode and Equals for key comparisons, so implementing the IComparable interface is not enough. Have a look at this answer, that's exactly what you need.

    0 讨论(0)
提交回复
热议问题