C# bits to bitmask int code example
Example: bitmasking in c#
[Flags]
public enum Days
{
None = 0,
Sunday = 1 << 0,
Monday = 1 << 1,
Tuesday = 1 << 2,
Wednesday = 1 << 3,
Thursday = 1 << 4,
Friday = 1 << 5,
Saturday = 1 << 6,
Workdays = Monday | Tuesday | Wednesday | Thursday | Friday,
Vacationdays = Saturday | Sunday,
AllDays = Workdays | Vacationdays
}
public Days myDays = Days.Wednesday | Days.Friday;
public bool containsTuesday = (myDays & Days.Tuesday) == Days.Tuesday ? true : false;
Console.WriteLine(containsTuesday);