Difficulty: Easy
Correct Answer: 1, 2, 5
Explanation:
Introduction / Context:
This checks foundational facts about enums in C#.NET: their inheritance, value/reference nature, printing, and default underlying type.
Given Data / Assumptions (Statements):
Concept / Approach:
An enum type ultimately derives from System.Enum
, which inherits from System.ValueType
, then System.Object
. Therefore, enums are value types. The default underlying type is int
unless specified otherwise. Enum values can be converted to strings via .ToString()
or Enum.GetName
.
Step-by-Step Evaluation:
System.Object
.2) True: Enums are value types by definition (ValueType
).3) False: myEnumValue.ToString()
prints the name; formatting options exist.4) False: Enums are not reference types.5) True: Default underlying type is int
.
Verification / Alternative check:
Run Console.WriteLine(MyEnum.SomeValue.ToString())
or use Enum.GetNames(typeof(MyEnum))
to list names.
Why Other Options Are Wrong:
Any option containing 3 or 4 contradicts well-documented enum behavior in .NET.
Common Pitfalls:
Confusing the ability to print names with numeric casts; both are available but serve different purposes.
Final Answer:
1, 2, 5
Discussion & Comments