使用哈希码的按钮颜色 [英] Button color using hash code

查看:100
本文介绍了使用哈希码的按钮颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!



我需要帮助!

我需要知道如何使用颜色的哈希码为按钮添加颜色。我用过这段代码:



Button1.BackColor.GetHashCode()



但我不知道如何使用此哈希码为另一个按钮添加颜色。



请帮助!



谢谢,

Nico

解决方案

哈希码只识别对象实例中的唯一性,它们并不意味着从其哈希码重构对象。 />


你应该使用 Color.FromArgb Color.ToArgb 获取所需的值。你无法从颜色的哈希码重建颜色。







这里< a href =http://blogs.msdn.com/b/ericlippert/archive/2011/02/28/guidelines-and-rules-for-gethashcode.aspx>是一个很好的讨论 [ ^关于哈希码的使用。



另请阅读
MSDN文档 [ ^ ]关于使用哈希码的注意事项。



[/编辑]


每个人都听过这样的话信息学的东西? :-)



从某个对象获取哈希码时,通常会丢失一些信息。它能告诉你什么吗?



(请参阅我对该问题的评论。)



< DD> -SA

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

解决方案

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]


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


这篇关于使用哈希码的按钮颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆