Back to questions
JuniorTheoryCommon
What does the program print (lines separated by spaces)?
Color c = Color.Blue;
Console.WriteLine(c);
Console.WriteLine((int)c);
Console.WriteLine((Color)5);
enum Color { Red, Green, Blue }Blue 2 5
- Expecting
(Color)5not to compile: an explicit cast takes anyint, and a value with no member name prints as its number,5. - Expecting
Blueto be3: members are numbered from zero unless you set the numbers, soRed,Green,Blueare0,1,2.
- How would you make
Redstart at1instead of0? - What does the compiler say about
Color c = 5;without a cast?