Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an enum named Days.
C Sharp (C#)
enum [1] { Sunday, Monday, Tuesday } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a name unrelated to the values like Months or Colors.
Leaving the enum name blank.
✗ Incorrect
The enum name should be Days to represent days of the week.
2fill in blank
mediumComplete the code to assign the enum value Monday to variable today.
C Sharp (C#)
Days today = Days.[1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a day not in the enum like Friday.
Using the enum name without the member.
✗ Incorrect
To assign Monday, use Days.Monday.
3fill in blank
hardFix the error in the code to compare enum values correctly.
C Sharp (C#)
if (today == Days.[1]) { Console.WriteLine("It's Monday"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or abbreviated names that don't match the enum.
Using strings instead of enum members.
✗ Incorrect
Enum members are case-sensitive and must match exactly, so use Monday.
4fill in blank
hardFill both blanks to create a switch statement that prints the day name.
C Sharp (C#)
switch (today) {
case Days.[1]:
Console.WriteLine("Sunday");
break;
case Days.[2]:
Console.WriteLine("Monday");
break;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using days not declared in the enum like Friday.
Using lowercase or abbreviated names.
✗ Incorrect
The switch cases must match the enum members Sunday and Monday.
5fill in blank
hardFill all three blanks to create a dictionary mapping enum days to their short names.
C Sharp (C#)
var dayShortNames = new Dictionary<Days, string> {
{ Days.[1], "Sun" },
{ Days.[2], "Mon" },
{ Days.[3], "Tue" }
}; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including days not in the enum like Friday.
Mismatching enum members and short names.
✗ Incorrect
The dictionary keys must be enum members Sunday, Monday, and Tuesday to match the short names.