Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi!

I need help!
I need to know how to add color to a button using the color's hash code. I used this code:

Button1.BackColor.GetHashCode()

but I don't know how to add color to another button using this hash code.

Help please!

Thanks,
Nico
Posted
Comments
Sergey Alexandrovich Kryukov 1-Jul-13 23:10pm    
Strange idea, to say the least. Why?
—SA

Hash codes only identify uniqueness in an object instance, they are not meant to reconstruct the object from its hash code.

You should be using the Color.FromArgb and Color.ToArgb to get the values you need. You can't reconstruct the color from the color's hash code.

[Edit]

Here is a great discussion[^] on the use of hash codes.

Also read MSDN documentation[^] on the do's and don'ts of working with hash codes.

[/Edit]
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 1-Jul-13 23:22pm    
Right, a 5. I also put some puzzled words in my answer... :-) Strange idea, indeed...
—SA
Ron Beyer 1-Jul-13 23:25pm    
Thanks, I 5'd yours too, between the two I think the point comes across :)
Espen Harlinn 2-Jul-13 10:40am    
5'ed!
Every heard of such thing as informatics? :-)

When you take a hash code from some object, you generally loose some information. Does it tell you something?

(Please see the my comment to the question.)

—SA
 
Share this answer
 
Comments
Espen Harlinn 2-Jul-13 10:40am    
5'ed!
Sergey Alexandrovich Kryukov 2-Jul-13 11:30am    
Thank you, Espen.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900