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