Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an enum named Color with values Red, Green, and Blue.
C Sharp (C#)
public enum Color [1] Red, Green, Blue }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of curly braces.
Using square brackets or angle brackets.
✗ Incorrect
Enums in C# are declared with curly braces { } to list their values.
2fill in blank
mediumComplete the code to declare a constant integer named MaxValue with value 100.
C Sharp (C#)
public const int MaxValue = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string "100" instead of number 100.
Using variable names instead of values.
✗ Incorrect
Constants are assigned a fixed value directly, here 100 as an integer.
3fill in blank
hardFix the error in the code to correctly assign the enum value Color.Green to variable selectedColor.
C Sharp (C#)
Color selectedColor = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using only the member name without enum type.
Trying to access enum members like an array.
✗ Incorrect
Enum values must be accessed with the enum type name, like Color.Green.
4fill in blank
hardFill both blanks to declare a constant string named Status with value "Active".
C Sharp (C#)
public const [1] Status = [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted text for string constants.
Using wrong type like int for string values.
✗ Incorrect
Constants need a type and a value; string type and quoted string value are required here.
5fill in blank
hardFill all three blanks to create a dictionary mapping enum Color to string names, including only Red and Blue.
C Sharp (C#)
var colorNames = new Dictionary<Color, [1]> { {Color.Red, [2], {Color.Blue, [3] };
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using int instead of string as dictionary value type.
Not quoting string values.
✗ Incorrect
The dictionary maps Color enum keys to string values representing their names.