C# Programming - Enumerations - Discussion

Discussion :: 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);

[A]. 1
[B]. -1
[C]. red
[D]. 0
[E]. color.red

Answer: Option C

Explanation:

No answer description available for this question.

Deepesh said: (Oct 10, 2012)  
Because internal type of enumeration is char. So it print red.

Vatan Soni said: (Dec 30, 2013)  
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:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.