From: Peter Duniho on
Tony Johansson wrote:
> [...]
> Now, suppose that I change the Name of instance2 to 'Paul', then, according
> to my Equals method, both instances should be equal, and according to the
> hashcode and equals method will generate the same hashCode(same key) and
> that is not allowed
> to have in a hashtable..
> What is the solution to this senario ?

Beyond the good advice you've already received, I'll point out that you
have not actually stated a _problem_ per se. So it's impossible to
propose a _solution_.

In particular, you've correctly stated the usage rules for hashtable
data structures, and you've intentionally implemented your class to
impose a specific usage restriction based on those rules. There does
not appear to be any actual problem. You simply have to work within the
rules.

If you don't like the constraints imposed on your code with your current
implementation, don't write code that imposes those constraints.

If you want a "solution" to some "problem", you need to state
specifically what that "problem" is.

Pete
First  |  Prev  | 
Pages: 1 2
Prev: Existing or pre-defined UITypeEditors
Next: f