C# Programming - Enumerations - Discussion

Discussion Forum : Enumerations - General Questions (Q.No. 14)
14.
Which of the following is the correct output for the C#.NET code snippet given below?
enum color
{
    red,
    green,
    blue 
}
color c = color.red;
Type t;
t = c.GetType();
string[ ]str;
str = Enum.GetNames(t);
Console.WriteLine(str[ 0 ]);
red
0
1
-1
color.red
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
1 comments Page 1 of 1.

Kate said:   1 decade ago
The variable t save the type "color".

Then str is assigned all the names in the enum "color".

Finally, you write the first element to the Console, which is red.

Post your comments here:

Your comments will be displayed after verification.