We were having a debate if enums should have uninitialized values. For example. We have
public enum TimeOfDayType { Morning Afternoon Evening }
or
public enum TimeOfDayType { None Morning Afternoon Evening }
I think that there shouldn’t be any none but then you have to default to some valid value on initialization. But others thought there should be some indication of uniitized state by having another enum that is None or NotSet.
thoughts?
Speaking of nullable types – I think they can be used to solve the problem of forcing/not forcing the initialization of an enum. Say we have
And let’s say you have a function:
That function says that it requires a valid
Color. However, we could also have this function:That says that the function can handle not being passed a color (
nullwould be passed to indicate ‘don’t care’).Well, it’s one alternative to
Nonemembers.