C# Programming - Enumerations - Discussion

Discussion Forum : Enumerations - General Questions (Q.No. 6)
6.
Which of the following will be the correct output for the C#.NET code snippet given below?
enum color : int
{
    red = -3,
    green,
    blue 
}
Console.Write( (int) color.red + ", "); 
Console.Write( (int) color.green + ", "); 
Console.Write( (int) color.blue );
-3, -2, -1
-3, 0, 1
0, 1, 2
red, green, blue
color.red, color.green, color.blue
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
1 comments Page 1 of 1.

Trishant Mishra said:   1 decade ago
By default enum value is increase by one in every time...

So -3
-3+1 = -2
-2+1 = -1

Post your comments here:

Your comments will be displayed after verification.