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.

Defining enums

Defining enums

- [Instructor] One of the other common types were used is an enum or an enumerated type. I'm just going to clean up a little of our code here, and we'll look at an example, go down below our existing code. From the framework, I can use a var day equals day of week, but with the dot you notice that I have a finite set of options here for the day of week. And this is where enums really makes sense, where you have a constrained set of values and you want to make it easier for people to select them. So I could come in and say Monday or my day and now if I look at day, it's got a number of different properties, all coming from the System.Enum type. So if we wrote out, day we see that there, so we're going to see console right up above is going to say dynamic from our dynamic object and then we'll see what Monday looks like. You can see, we get a string value there for Monday, but if I have over day, just as day of week. If I have over a day a week, Monday, it says one and day of week is an…

Contents