C# Programming - Enumerations - Discussion

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

Lama Paska said:   6 years ago
Then, what will be the value of blue?
(1)

Ashish Kalmegh said:   1 decade ago
By default as per sequence the index value is shown , so after

magenta = 10,
yellow becomes 11

this is the index

enum color: int
{
red = 0,
green = 1,
blue = 5,
cyan = 6,
magenta = 10,
yellow = 11
}

Post your comments here:

Your comments will be displayed after verification.