Using ToArgb() followed by FromArgb() does not result in the original color

前端 未结 4 1281
清酒与你
清酒与你 2021-01-13 04:35

This does not work

        int blueInt = Color.Blue.ToArgb();
        Color fred = Color.FromArgb(blueInt);
        Assert.AreEqual(Color.Blue,fred);
         


        
4条回答
  •  情深已故
    2021-01-13 05:12

    From the MSDN documentation on Color.operator ==:

    This method 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.

    I'm guessing the state flags are different.

提交回复
热议问题