Skip to content
Discussion options

You must be logged in to vote

You need to constrain TEnum to struct. (SharpLab)

static bool GetFlag<TEnum>(TEnum? field, TEnum flag)
    where TEnum : struct, Enum
    => field?.HasFlag(flag) == true;

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@miroslav22
Comment options

@PathogenDavid
Comment options

Answer selected by miroslav22
Comment options

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