0

I want to enter a number and have the console program return the name of the item from an enum

using System;

namespace ConsoleApp7
{
    class Program
    {
        enum planets { Mercury = 1, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune};
        static void Main(string[] args)
        {
            int selection = Convert.ToInt32(Console.ReadLine());
            selection = enum planets;
            Console.WriteLine("{0} is {1} planet(s) from the sun", planets, selection);
            Console.Readkey();
        }
    }
}
Vector 2755
  • 37
  • 1
  • 5

1 Answers1

1
int selection = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("{0} is {1} planet(s) from the sun", (planets)selection, selection);
Nehorai Elbaz
  • 2,412
  • 8
  • 17