Let\'s say I have this enum:
[Flags]
enum Letters
{
A = 1,
B = 2,
C = 4,
AB = A | B,
All = A | B | C,
}
To check i
There are two aproaches that I can see that would work for checking for any bit being set.
Aproach A
if (letter != 0)
{
}
This works as long as you don't mind checking for all bits, including non-defined ones too!
Aproach B
if ((letter & Letters.All) != 0)
{
}
This only checks the defined bits, as long as Letters.All represents all of the possible bits.
For specific bits (one or more set), use Aproach B replacing Letters.All with the bits that you want to check for (see below).
if ((letter & Letters.AB) != 0)
{
}