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:
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
Post a Comment