Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Compare KnownColor to Color

I would like to know how I can compare a "System.Drawing.KnownColor" with a "System.Drawing.Color".

Just testing with "IsNot" is not allowed. VB.NET tells me that these 2 objects are not comparable.

I see that KnowColor has the function "CompareTo" which does accept Color as an argument, but the return value is not a Boolean but an Integer. So I am not sure if that is really what I am looking for.

like image 698
tmighty Avatar asked Dec 21 '25 12:12

tmighty


1 Answers

Use Color.FromKnownColor() to get a corresponding Color instance at runtime, and then you will be able to compare them.

like image 52
d3dave Avatar answered Dec 23 '25 03:12

d3dave



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!