C#.NET Enums — identify the correct statement about default values and member rules. Consider general behavior of enum members in C#.NET (underlying integral types, default starting value, naming rules, and assignment constraints). Choose the single correct statement from the options below.

C# Programming Enumerations Difficulty: Easy
Choose an option
  • A
    By default, the first enumerator has the value 0 (unless an explicit value is provided).
  • B
    The value of each successive enumerator is decreased by 1 automatically.
  • C
    An enum member name may contain whitespace characters.
  • D
    You can assign a non-const variable directly to an enum member at its declaration.
  • E
    Enum element values cannot be obtained from a database and used at runtime.

Answer

Correct Answer: By default, the first enumerator has the value 0 (unless an explicit value is provided).

Explanation

Introduction / Context:Enums in C#.NET provide a named set of integral constants. Understanding their default underlying values, naming rules, and the compile-time constant requirement is essential.

Given Data / Assumptions:

  • Default underlying type is int.
  • First member defaults to 0.
  • Members increment by 1 unless overridden.
  • Names must be valid identifiers.
  • Initializers must be compile-time constants.

Concept / Approach:Members are sequentially numbered starting at 0 unless explicitly given a constant. Non-const variables are invalid at declaration, but values can be cast from database data at runtime.

Final Answer:By default, the first enumerator has the value 0 (unless an explicit value is provided).

Discussion & Comments
No comments yet. Be the first to comment!
Join Discussion