0
0
C Sharp (C#)programming~10 mins

Enum declaration syntax in C Sharp (C#) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare an enum named Color.

C Sharp (C#)
enum [1] { Red, Green, Blue }
Drag options to blanks, or click blank then click option'
AColor
Bcolor
CColors
DcolorEnum
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase names for enums.
Using plural form when singular is expected.
2fill in blank
medium

Complete the code to specify the underlying type of the enum as byte.

C Sharp (C#)
enum Status : [1] { Active, Inactive, Pending }
Drag options to blanks, or click blank then click option'
Aint
Bbyte
Cstring
Dbool
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-integral types like string or bool as underlying type.
Omitting the colon before the type.
3fill in blank
hard

Fix the error in the enum declaration by completing the code.

C Sharp (C#)
enum Days [1] Monday, Tuesday, Wednesday }
Drag options to blanks, or click blank then click option'
A{
B(
C[
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses or brackets instead of braces.
Omitting braces entirely.
4fill in blank
hard

Fill both blanks to declare an enum named Direction with underlying type short.

C Sharp (C#)
enum [1] : [2] { North, South, East, West }
Drag options to blanks, or click blank then click option'
ADirection
Bshort
Cint
DCompass
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong underlying types like int when short is required.
Using incorrect enum names.
5fill in blank
hard

Fill all three blanks to declare an enum named Level with underlying type int and members Low, Medium, High.

C Sharp (C#)
enum [1] : [2] { [3] }
Drag options to blanks, or click blank then click option'
ALevel
Bint
CLow, Medium, High
DLevels
Attempts:
3 left
💡 Hint
Common Mistakes
Using plural enum names when singular is expected.
Omitting commas between enum members.