C#C
C#11mo ago
Faker

✅ Enums in C#

Hello guys, I'm learning about what an "enum" is, I often saw this word several times without really understanding what it is or how it works.

So from what I've read, an enum is a distinct value type which represents a set of constants.

We declare one as follows:

enum DaysOfWeeks
{
...
}

Enums are mostly used where we need to represent "options". It is more user-friendly because it's easier to read if (color == Colors.Red) than if (color == 1).

This is what I understood so far, is there anything else to add please
Was this page helpful?