[Mono-dev] GetHashCode() implementation for class string

Alan McGovern alan.mcgovern at gmail.com
Sun Dec 7 17:47:43 EST 2008


On Mon, Dec 1, 2008 at 9:44 PM, CarGa <carga at mail.ru> wrote:

> Hello, all!
>
> I was directed here by Atsushi Eno from mono-olive list with this
> question/request about GetHashCode() method.
>
> DependencyProperty class (that lays at the very base of entire WWF and WPF
> libraries) heavily depends on quality of GetHashCode() method since we use
> it to find any particular DependencyProperty in some huge Dictionary<int,
> DependencyProperty> of others.
>

If i understand correctly, you're using the hashcode fo a DP as a unique
identifier. This is wrong. Hashcodes are by definition *not* a unique
identifer and should not be used as such. You're completly misusing the
hashcode in this case. Your code will never run correctly if you are using
.GetHashCode() to supply the 'int' in Dictionary<int, DependencyProperty>

Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20081207/a484e93c/attachment.html 


More information about the Mono-devel-list mailing list