Skip to content
Discussion options

You must be logged in to vote

I think the situation is somewhat improved by extension properties:

MyDaysOfWeek days = MyDaysOfWeek.Monday;
if (days is { HasMonday: true, HasTuesday: false, HasWednesday: true })
{
    // handling for Monday + Wednesday schedules
}

[Flags]
public enum MyDaysOfWeek
{
    Monday = 1 << 0,
    Tuesday = 1 << 1,
    Wednesday = 1 << 2,
    Thursday = 1 << 3,
    Friday = 1 << 4,
    Saturday = 1 << 5,
    Sunday = 1 << 6
}

public static class MyDaysOfWeekExtensions
{
    extension(MyDaysOfWeek value)
    {
        public bool HasMonday => (value & MyDaysOfWeek.Monday) == MyDaysOfWeek.Monday;
        public bool HasTuesday => (value & MyDaysOfWeek.Tuesday) == MyDaysOfWeek.Tuesday;
        p…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@franchyd
Comment options

@HaloFour
Comment options

@KryKomDev
Comment options

@ZlomenyMesic
Comment options

@franchyd
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by KryKomDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants