From the course: C# Essential Training 1: Types and Control Flow

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Enabling multiple enum values

Enabling multiple enum values

- [Instructor] If we try to take our type an add by using a Bitwise operator like the or, let's say Thursday. What we'd like is for our days available when we represent it or say D days available here in our console right line to show Wednesday and Thursday. We're combining those two values. If we do this, we run it, you'll see we get 24, which is Thursday plus Wednesday. It is 16 plus 8, and that is the integer value, but that's not really what we want. Certainly we could store it in the database that way, that's why we numbered them this way. But we don't really want that. What we want to be able to do is treat them a little more like Bitwise operators with flags. So we can add an attribute called flags to our enum. And that essentially tells the compiler to treat it a little bit differently and that this particular enum can have multiple values in it. So simply by adding that flags attribute, if I run it now, we see we get Wednesday, Thursday. That's what we would expect in our…

Contents