c# - Why is this Brush with a #00FFFFFF value not equal to Brushes.Transparent? -


i'm retrieving list of brushes via reflection class. want make sure brush in list not transparent (#00ffffff). however, comparing brushes.transparent returns false though value in fact #00ffffff.

var brushes = getlistofbrushes(); var brush = brushes.first(c => c != brushes.transparent);     console.writeline(brush); // prints "#00ffffff" 

the reliable way in case check string representation if starts `#00" feels hacky.

in example screenshot below brush returned first() call matches predicate although should not:

enter image description here

since compare brushes want cast<solidcolorbrush>() or pre-filtering if aren't solid colors (i.e. not transparent default).

you can compare brush.color brushes.transparent.color.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -