How to compare a Color by the GetPixel Method and a Color passed in a method like Color.Black?

According to MSDN, the Color.Equality Operator…

…compares more than the ARGB values of the Color structures. It also does a comparison of some state flags. If you want to compare just the ARGB values of two Color structures, compare them using the ToArgb method

So the method that you are using is correct for comparing the raw values

EDIT

.ToArgb() returns an int so you can just use == for comparison, you don’t need to use .Equals() if you find it too verbose.

Leave a Comment