Difficulty: Easy
Correct Answer: blue
Explanation:
Introduction / Context:This question checks how enums print when written to the console and confirms correct case matching in a switch statement over an enum.
Given Data / Assumptions:
Concept / Approach:Console.WriteLine on an enum value writes the identifier name by default (not the underlying numeric value), unless formatted otherwise. Matching case color.blue triggers printing of "blue".
Step-by-Step Solution:
Switch discriminant is color.blue. Case color.blue matches; Console.WriteLine(color.blue) executes. The console prints the enum member name: "blue".Verification / Alternative check:If you cast to int, e.g., (int)color.blue, you would see 2. Without casting, the name is printed.
Why Other Options Are Wrong:
Common Pitfalls:Assuming enums print as numbers by default or believing switch falls through and prints multiple lines (it does not due to break statements).
Final Answer:blue
Discussion & Comments