C# how to use enum keyword
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace enumkeyword
{
class Program
{
enum traffic { red, yellow, green }
static void Main(string[] args)
{
int trafstart = (int)traffic.red;
int trafmiddle = (int)traffic.yellow;
int trafend = (int)traffic.green;
Console.WriteLine("Red {0}",trafstart);
Console.WriteLine("Yellow {0}", trafmiddle);
Console.WriteLine("Green {0}",trafend);
Console.ReadKey();
}
}
}
Output