0

I am working with a DevExpress enumeration that has the following structure:

public enum RecurrenceDay
{
    Sunday = 1,
    Monday = 2,
    Tuesday = 4,
    Wednesday = 8,
    Thursday = 16,
    Friday = 32,
    Saturday = 64,
    WeekendDays = Sunday | Saturday,
    WorkDays = Monday | Tuesday | Wednesday | Thursday | Friday,
    EveryDay = WeekendDays | WorkDays
}

If the User choose Sunday and Monday inside the DevExpress control, the value stored is 3 which is the Sum of Sunday(1) + Monday(2). My problem is the following, I need to know from a number which values have been chosen from the enumeration.

Example:
6 = []{ Monday, Tuesday };

Is this possible without creating a lookup table that contains all possible combinations?

Raffaeu
  • 5,861
  • 9
  • 58
  • 99
  • 2
    see `Enum.HasFlag()`: https://msdn.microsoft.com/en-us/library/system.enum.hasflag%28v=vs.110%29.aspx – DrKoch May 01 '15 at 11:34
  • 1
    FYI: They're not the sum per se, they are the result of `or`ing the values together. See http://en.wikipedia.org/wiki/Bitwise_operation – Jamiec May 01 '15 at 11:40

0 Answers0