比较两个颜色的物体物体、颜色、两个

2023-09-03 21:41:58 作者:见你爱笑

本C#,Visual Studio 2010和.NET 4.0。我想比较两个的System.Drawing.Color 的对象。

This C#, VS2010 and .NET 4.0. I'm trying to compare two System.Drawing.Color objects.

的值 mStartColor.ToArgb() 16777215

的值 Col​​or.Transparent.ToArgb() 16777215

mStartColor 1所述的价值;> Color.Transparent

如何平等实施了颜色对象?

谢谢大家。我有我的答案,但它并没有多大意义,我(见我的意见蒂姆和戴夫的回答如下)。我会纪念Tim的岗位作为答案,他是第一个回复,但戴夫的回答也同样丰富。

Thanks everyone. I got my answer, though it doesn't make much sense to me (see my comments to Tim's and Dave's answers below). I'll mark Tim's post as the answer and he was the first to reply, but Dave's answer is equally informative.

推荐答案

经常阅读的文档第一:

比较仅凭其ARGB值为主色调,你应该使用   该ToArgb方法。这是因为Equals和平等成员   确定等效使用超过的只是ARGB值   颜色。例如,黑色和FromArgb(0,0,0)不被视为   相等的,因为黑色是一个名为色和FromArgb(0,0,0)不是

"To compare colors based solely on their ARGB values, you should use the ToArgb method. This is because the Equals and Equality members determine equivalency using more than just the ARGB value of the colors. For example, Black and FromArgb(0,0,0) are not considered equal, since Black is a named color and FromArgb(0,0,0) is not"