C# Programming - Enumerations - Discussion

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

Deepesh said:   1 decade ago
Because internal type of enumeration is char. So it print red.

Vatan soni said:   1 decade ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
enum color
{
red,
green,
blue
}
static void Main(string[] args)
{
color c;
c = color.red;
Console.WriteLine(c);
Console.Read();
}
}
}

O/P == red.

Post your comments here:

Your comments will be displayed after verification.