[Flags]
public enum Category
{
Undefined = 0,
AdultsOnly = 1,
Family = 2,
AllInclusive = 4,
City = 8
}
void Main()
{
Category c = Category.AdultsOnly | Category.City; Category[] categories = new Category[2] { Category.AllInclusive, Category.Family};
Category category = categories.Aggregate((i, t) => i | t);
var isThereAtLeastOneMatch = (c & category) != Category.Undefined;
var hasExact = (c & Category.AdultsOnly )== Category.AdultsOnly;
}
No comments:
Post a Comment