You should use an enum:
[Flags]
public enum WeekDays
{
Sunday = 1,
Saturday = 2,
Friday = 4,
Thursday = 8,
Wednesday = 16,
Tuesday = 32,
Monday = 64
}
A simple explicit conversion will do the "remapping" you're interested in:
WeekDays days = (WeekDays) 28;
You can easily use normal bitwise operations:
if ((days & WeekDays.Friday) != 0)
{
// Yes, the mask included Friday
}
And you could do that in a loop:
foreach (WeekDays day in Enum.GetValues(typeof(WeekDays))
{
if ((days & day) != 0)
{
Console.WriteLine("Got {0}", day);
}
}
Even just using Console.WriteLine(days)
will give you a comma-separated representation.
You may also find the utility methods in my Unconstrained Melody library useful (in particular the Flags
code).
If you're looking for something else, please be more specific.