Click here to Skip to main content
15,884,739 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

See if a Flags enum is valid

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
16 May 2011CPOL 4.4K  
// A faster solutionreturn (value & mask) == 0;// Where mask == ~ (None | One | Eight)// This constant can be precomputed at compile-time or run-time (like in Alternate 1)
// A faster solution
return (value & mask) == 0;

// Where mask == ~ (None | One | Eight)
// This constant can be precomputed at compile-time or run-time (like in Alternate 1)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO VISION fOr VISION
Belgium Belgium
I fell into applied algorithmics at the age of 16 or so. This eventually brought me to develop machine vision software as a professional. This is Dreamland for algorithm lovers.

Comments and Discussions

 
-- There are no messages in this forum --