Recall & Review
beginner
What is an enum in C#?
An enum (short for enumeration) is a special data type that lets you define a group of named constant values. It helps make code easier to read and maintain.
Click to reveal answer
beginner
Why use enums instead of plain numbers or strings?
Enums give meaningful names to values, reducing mistakes and making code clearer. They also help the compiler catch errors if you use invalid values.
Click to reveal answer
intermediate
How do enums improve code safety?
Enums restrict variables to a set of predefined values, so you can't accidentally assign invalid values. This prevents bugs and makes the program more reliable.
Click to reveal answer
beginner
Give a real-life example where enums are useful.
For example, days of the week can be an enum with values like Monday, Tuesday, etc. This avoids using numbers like 1 or 2, which can be confusing.
Click to reveal answer
beginner
How do enums help with code readability?
Using enums means you write names like 'Red' or 'Green' instead of numbers like 1 or 2. This makes the code easier to understand for anyone reading it.
Click to reveal answer
What does an enum represent in C#?
✗ Incorrect
Enums define a group of named constants, making code clearer and safer.
Why are enums safer than using plain numbers?
✗ Incorrect
Enums restrict variables to specific values, preventing invalid assignments.
Which of these is a good use case for enums?
✗ Incorrect
Days of the week are fixed named values, perfect for enums.
How do enums improve code readability?
✗ Incorrect
Enums use descriptive names that make code easier to understand.
What happens if you assign a value not in the enum?
✗ Incorrect
The compiler checks enums and reports errors for invalid values.
Explain why enums are useful in programming and how they help prevent errors.
Think about how giving names to fixed options helps programmers.
You got /4 concepts.
Describe a real-life example where using an enum would make code easier to read and maintain.
Consider common lists of fixed options in daily life.
You got /4 concepts.