Compare two Color objects

前端 未结 3 1614
我寻月下人不归
我寻月下人不归 2020-12-03 14:14

This is VS2010 and .NET 4.0. I\'m trying to compare two System.Drawing.Color objects.

The value of mStartColor.ToArgb() is 16777215

3条回答
  •  一生所求
    2020-12-03 15:15

    Always read the documentation first:

    "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"

提交回复
热议问题