I\'d like one general purpose function that could be used with any Flags style enum to see if a flag exists.
This doesn\'t compile, but if anyone has a suggestion, I
I have used this before:
public static bool In(this T me, T values)
where T : struct, IConvertible
{
return (me.ToInt64(null) & values.ToInt64(null)) > 0;
}
What I like about it is you can use this clean syntax to call it since in 3.5 the compiler will can infer generic parameters.
AttributeTargets a = AttributeTargets.Class;
if (a.In(AttributeTargets.Class | AttributeTargets.Module))
{
// ...
}