- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Programming_Console
- {
- class Program
- {
- enum Color
- {
- Red, Green, Blue, Yellow, Pink, Grey
- }
- static void Main(string[] args)
- {
- Color check = Color.Green;
- Console.WriteLine("Enter the color name");
- switch (check)
- {
- case Color.Green:
- Console.WriteLine("Color is Green");
- break;
- case Color.Blue:
- Console.WriteLine("Color is blue");
- break;
- case Color.Yellow:
- Console.WriteLine("Color is Yellow");
- break;
- case Color.Grey:
- Console.WriteLine("Color is Grey");
- break;
- case Color.Pink:
- Console.WriteLine("Color is Pink");
- break;
- case Color.Red:
- Console.WriteLine("Color is Red");
- break;
- default:
- Console.WriteLine("Illegal Color");
- break;
- }
- Console.ReadLine();
- }
- }
- }
This program for how to Use an Enum example with Switch.
