Re: [ADVANCED-DOTNET] GetHashCode() method

2005-06-27 Thread Frans Bouma
> You can get dupes with GetHashCode(); but two objects with > the same "value" must have the same hash code. > I'll admit that Equals() must be overridden when > GetHashCode() is overridden; but, I disagree that > GetHashCode() is used wherever Equals() is used. Heh I agree, though I thin

Re: [ADVANCED-DOTNET] GetHashCode() method

2005-06-27 Thread Frans Bouma
> At 02:49 PM 6/27/2005, Frans Bouma wrote (in part) > >> There's been some discussion lately regarding the > >> Object.GetHashCode() method. > >> > >> I think the concensus is pretty clear: for best > reliability, classes > >> that implement GetHashCode() should be immutable. > > > >Why? y

Re: [ADVANCED-DOTNET] GetHashCode() method

2005-06-27 Thread Bogdan Lachendro
On 2005-06-27 21:19, Peter Ritchie wrote: Hashtable.ContainsKey is basically looping until (entry.key.GetHashCode() == keyParameter.GetHashCode() && entry.key.Equals(keyParameter)) == true. To be clear: The hashtable actually uses a bit different algorithm. The hash code is used to determine t

Re: [ADVANCED-DOTNET] GetHashCode() method

2005-06-27 Thread Peter Ritchie
See comments below. On Mon, 27 Jun 2005 15:37:18 -0400, J. Merrill <[EMAIL PROTECTED]> wrote: >I think the right way to say it is that if the GetHashCode result >is computed from values of one or more properties (or fields) of >the object, those values must be immutable -- either that, or special

Re: [ADVANCED-DOTNET] GetHashCode() method

2005-06-27 Thread Peter Ritchie
You can get dupes with GetHashCode(); but two objects with the same "value" must have the same hash code. I'll admit that Equals() must be overridden when GetHashCode() is overridden; but, I disagree that GetHashCode() is used wherever Equals() is used. As with any hash, objects of save "value" *

Re: [ADVANCED-DOTNET] GetHashCode() method

2005-06-27 Thread J. Merrill
At 02:49 PM 6/27/2005, Frans Bouma wrote (in part) >> There's been some discussion lately regarding the >> Object.GetHashCode() method. >> >> I think the concensus is pretty clear: for best reliability, >> classes that implement GetHashCode() should be immutable. > >Why? you can also get du

Re: [ADVANCED-DOTNET] GetHashCode() method

2005-06-27 Thread Frans Bouma
> There's been some discussion lately regarding the > Object.GetHashCode() method. > > I think the concensus is pretty clear: for best reliability, > classes that implement GetHashCode() should be immutable. Why? you can also get dupes with GetHashCode. It's not as if it's a magic value.

[ADVANCED-DOTNET] GetHashCode() method

2005-06-27 Thread Peter Ritchie
There's been some discussion lately regarding the Object.GetHashCode() method. I think the concensus is pretty clear: for best reliability, classes that implement GetHashCode() should be immutable. Other than the Hashtable and ProperytCollection classes, does anyone know where GetHashCode() is us