If you have an enumeration that's is declared inside another class rather than being declared inside a namespace then you qualify the property type using classname.enumname. That it is a flags enum is irrelevant, as too is the fact that it is an enum. Anything declared inside another class is qualified with the outer class name followed by the inner class name
Taking in the advice in the comments for better naming too, consider something like:
public class EventSchedules{
[Flags]
public enum WeekDays { //name flags enums as plural
Mon=1,Tue=2,Wed=4,Thu=8,Fri=16,Sat=32,Sun=64
}
}
public class RecurringEvent{
public EventSchedules.WeekDays OccursOn { get; private set; }
}
You should consider not to use 0 as a value for your one of your enum items unless you're going to remember to compare it numerically. The normal way to test for a flags enum containing a flag is like one of these:
WeekDays x = WeekDays.Tue | WeeksDays.Wed;
//this way
if(x.HasFlag(WeekDays.Tue)) ...
//or this way
if(x & WeekDays.Tue == WeekDays.Tue) ...
If you made Mon = 0
then both of these would return true when testing against Monday (x.HasFlag(Mon)) //returns true, isn't true
) even if the x
didn't contain Monday. This is because you cannot look at a number 7 and say concretely whether it contains a 0 or not - was it 4+2+1 or 4+2+1+0 ?
You could remember to do a straight compare without any masking like if(x == Mon)
but then you have to wonder "did it mean that Mon was set, or that the user forgot to set a value?"
Maybe better to just make Mon=1 (and have a None=0)
ps; Public Things In C# Have PascalCase Names