Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace CsharpCourse
- {
- internal class Program
- {
- // enum
- public enum Color
- {
- red,
- green,
- blue,
- pink = 6,
- white,
- black
- }
- static void Main(string[] args)
- {
- /*
- foreach(var color in Enum.GetNames(typeof(Color)))
- {
- Console.WriteLine($"{color} = {(int)Enum.Parse(typeof(Color) , color)}");
- }
- */
- while (true)
- {
- Console.WriteLine("Select the BackGround Color");
- foreach (var color in Enum.GetNames(typeof(ConsoleColor)))
- {
- Console.WriteLine(color);
- }
- string input = Console.ReadLine();
- ConsoleColor selectedColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), input, true);
- Console.BackgroundColor = selectedColor;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement