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 - C# Tutorial
From the course: C# Essential Training 1: Types and Control Flow
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Defining enums4m 39s
-
(Locked)
Enabling multiple enum values4m 3s
-
(Locked)
Testing enum values4m 13s
-
(Locked)
Understanding nullable types3m 24s
-
(Locked)
Using nullable types2m 14s
-
(Locked)
Working with null objects3m 25s
-
(Locked)
Understanding nullable reference types4m 23s
-
(Locked)
Working with nullable reference types4m 8s
-
(Locked)
Solution: Enum Flags1m 42s
-
(Locked)
-
-