I want to be able to determine if an enum value belongs to a certain group. See the pseudo example:
[Flags]
public enum Animals
{
Dog = 1,
Cat = 2,
WildAnimal = Dog | Cat,
Fly = 4,
Bee = 8,
Insect = Fly | Bee
}
public static bool IsInsect(Animals animals)
{
return Animals.Insect.Qualifies(animals);
}
public static bool Qualifies(this Animals groupName, Animals value)
{
//Is there a bitwise operation for it?
}
Use
HasFlagmethod on enum.http://msdn.microsoft.com/en-us/library/system.enum.hasflag.aspx