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 );
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
}
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:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers