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);
Discussion:
2 comments Page 1 of 1.
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.
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.
Deepesh said:
1 decade ago
Because internal type of enumeration is char. So it print red.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers