I have this,
public enum Condition : uint // bitwise
{
None = 0,
NewLine = 1,
Space = 2
}
Rule.Condition someCondition = Rule.Condition.Space | Rule.Condition.NewLine;
I'd like to convert this,
if ((Rule.Condition.Space & condition) == Rule.Condition.Space) return true;
if ((Rule.Condition.NewLine & condition) == Rule.Condition.NewLine) return true;
Into something like,
if((someCondition & condition) == someCondition) return true;
But it isn't working. What am I forgetting?
Well, if you're just wanting to test for none, then check for > 0
. But, if you're looking for a less specific solution, something like this would combine the two and remove the if
altogether:
return (int)(someCondition & (Condition.Space | Condition.NewLine)) > 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With