gpt4 book ai didi

c# - 使用 ToArgb() 后跟 FromArgb() 不会产生原始颜色

转载 作者:太空狗 更新时间:2023-10-29 22:25:10 24 4
gpt4 key购买 nike

这行不通

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

有什么建议吗?

[编辑]

我正在使用 NUnit,输出是

失败:

预期:颜色 [蓝色]

但是是:颜色 [A=255, R=0, G=0, B=255]

[编辑]

这行得通!

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

最佳答案

来自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.

我猜州旗是不同的。

关于c# - 使用 ToArgb() 后跟 FromArgb() 不会产生原始颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/721324/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com