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

Posted by hayrob on Stack Overflow See other posts from Stack Overflow or by hayrob
Published on 2009-04-06T12:58:33Z Indexed on 2010/04/17 23:13 UTC
Read the original article Hit count: 357

Filed under:
|
|
|

This does not work

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

Any suggestions?

[Edit]

I'm using NUnit and the output is

failed:

Expected: Color [Blue]

But was: Color [A=255, R=0, G=0, B=255]

[Edit]

This works!

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

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET