switch case for one enum type return another c# code example

Example 1: enum switch menu c#

enum Menu
        {
            Students_Detail = 1,
            Display = 2,
            Exit = 3
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Please select a menu option");
            Console.WriteLine("1. Students Detail");
            Console.WriteLine("2. Display");
            Console.WriteLine("3. Exit");
            int pick = Convert.ToInt32(Console.ReadLine());
            Menu menuChoice = new Menu();
            menuChoice = (Menu)pick;

            switch (pick)
            {
                case 1:
                    break;
                case 2:
                    break;
                case 3:
                    break;
                default:
                    break;
            }
        }

Example 2: multi case in c#

switch (value)
{
   case var s when new[] { 1,2,3 }.Contains(s):
      // Do something
      break;
   case var s when new[] { 4,5,6 }.Contains(s):
      // Do something
      break;
   default:
      // Do the default
      break;
}