C# Fundamentals: Combining Enum Values with Bit-Flags

added by mopen
7/23/2010 8:26:27 PM

1 Kicks, 128 Views

You may notice we decorated our enum with a [Flags] attribute. You may also notice we skipped the value of 3 in our enumeration, we’ll get to each of these points in turn in the sections that follow, for now take it on faith that these steps are best practices and you'll soon see the reason. So now, this definition of a [Flags] enum will allow us to have a MessagingProperties value that is both Durable and Persistent, or is both Buffered and Durable, or is all three, or is none of the three, and so on and so on. But how would we represent this in code?