title: C# Menu and SubMenu on Console-Troubles on Menu Return
body: <p>I am new at programming and I'm trying to create a Menu that has inside Submenus. The main Menu has all the options to procede while the submenu has a CRUD for each options inserted.</p>
  
  <p>However the submenu I've done(Animals)doesn't work neither of the visualize by id methods and it goes like this to the following crud methods for the submenus. Also when a submenu complets its tasks it should return to the initial Submenu options, allowing to return to main Menu by pressing zero. Which is  not happening, though I tryied doing things differently. I'm not sure if it's the switch statement which wrong or if it's the methods call. </p>
  
  <p>Sorry if the code is a little bigger than usual:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace menu
  {
      class Program
      {
          public static int id = 1;
          enum animalHeader { id, name, client_name, type_animal };
          enum clientHeader { id, name, client_surname, adrress };
          static void Main(string[] args)
          {
              string[,] animal = new string[20, 4];
              string[,] client = new string[20, 6];
  
              do { MenuOptions(animal); } while (true);
  
          }
          static void MenuOptions(string[,] animal)
          {
              int userChoice;
  
              do
              {
                  Console.Clear();
                  Console.WriteLine("\nChoose one of the following options:\n");
  
                  Console.WriteLine("[ 1 ] Animals");
                  Console.WriteLine("[ 2 ] Clients");
                  Console.WriteLine("[ 0 ] Quit application\n");
  
              } while (!int.TryParse(Console.ReadLine(), out userChoice) || userChoice &lt; 0 || userChoice &gt; 2);
  
              Console.Clear();
  
              switch (userChoice)
              {
                  case 1:
                      menuAnimal(animal);
                      menuReturn(animal);
                      break;
                  case 2:
                      //menuClient(client);
                      mainMenu();
                      break;
                  case 0:
                      Environment.Exit(0);
                      break;
                  default:
                      Console.WriteLine("Try again!!");
                      break;
              }
          }
          static void menuAnimal(string[,] animal)
          {
              int optAnimal;
  
              do
              {
                  Console.Clear();
                  Console.WriteLine("\nInsert one of the following options:\n");
  
                  Console.WriteLine("[ 1 ] Insert animal");
                  Console.WriteLine("[ 2 ] See animal");
                  Console.WriteLine("[ 3 ] Alter animal");
                  Console.WriteLine("[ 4 ] Erase animal");
                  Console.WriteLine("[ 5 ] List animals");
                  Console.WriteLine("[ 0 ] Return to main menu\n");
  
              } while (!int.TryParse(Console.ReadLine(), out optAnimal) || optAnimal &lt; 0 || optAnimal &gt; 5);
  
              Console.Clear();
  
              switch (optAnimal)
              {
                  case 1:
                      insertData(animal);
                      menuReturn(animal);
                      break;
                  case 2:
                      visualizeByid(animal);
                      menuReturn(animal);
                      break;
                  case 3:
                      updateById(animal);
                      menuReturn(animal);
                      break;
                  case 4:
                      deleteByid(animal);
                      menuReturn(animal);
                      break;
                  case 5:
                      listData(animal);
                      menuReturn(animal);
                      break;
  
              }
          }
          static void mainMenu()
          {
              Console.Clear();
              Console.ReadKey();
          }
  
          static void menuReturn(string[,] animal)
          {
              Console.Clear();
  
              do { menuAnimal(animal); } while (true);
  
          }
  
          static int generateId()
          {
              return id++;
          }
          static int getInsertIndex(string[,] matrix)
          {
              for (int j = 0; j &lt; matrix.GetLength(0) - 1; j++)
              {
                  if (string.IsNullOrEmpty(matrix[j, 0])) return j;
              }
  
              return -1;
          }
          static void insertData(string[,] matrix)
          {
              int id = generateId();
              int n = getInsertIndex(matrix);
  
              matrix[n, 0] = Convert.ToString(id);
  
              for (int j = 1; j &lt; matrix.GetLength(1); j++)
              {
                  do
                  {
                      Console.Write($"Insert {Enum.GetName(typeof(animalHeader), j)}: ");
                      matrix[n, j] = Console.ReadLine();
                  } while (String.IsNullOrEmpty(matrix[n, j]));
              }
          }
          static int searchId(string[,] matrix)
          {
              int choosenId, index = -1;
  
              do
              {
                  Console.Write("Insert ID to continue: ");
  
              } while (!int.TryParse(Console.ReadLine(), out choosenId));
  
  
              for (int i = 0; i &lt; matrix.GetLength(0); i++)
              {
                  if (Convert.ToString(choosenId) == matrix[i, 0])
                  {
                      index = i;
                  }
              }
  
              return index;
          }
          static void visualizeByid(string[,] matrix)
          {
              int pos = searchId(matrix);
  
              if (pos != -1)
              {
                  for (int i = pos; i &lt; pos + 1; i++)
                  {
                      for (int j = 0; j &lt; matrix.GetLength(1); j++)
                      {
                          Console.Write($"{matrix[i, j]}\t");
                      }
                      Console.WriteLine();
                  }
              }
              else { Console.WriteLine("Wrong Id"); }
          }
          static void updateById(string[,] matrix)
          {
              int pos = searchId(matrix);
              if (pos != -1)
              {
                  for (int i = pos; i &lt; pos + 1; i++)
                  {
                      for (int j = 1; j &lt; matrix.GetLength(1); j++)
                      {
                          Console.Write($"Insert {Enum.GetName(typeof(animalHeader), j)}:  ");
                          matrix[i, j] = Console.ReadLine();
                      }
                      Console.WriteLine();
                  }
              }
              else { Console.WriteLine("Id does not exist"); }
          }
          static void deleteByid(string[,] matrix)
          {
              int pos = searchId(matrix);
              if (pos != -1)
              {
                  for (int i = pos; i &lt; pos + 1; i++)
                  {
                      for (int j = 0; j &lt; matrix.GetLength(1); j++)
                      {
                          matrix[i, j] = null;
                      }
                  }
              }
              else { Console.WriteLine("Id does not exist"); }
          }
          static void listData(string[,] matrix)
          {
              for (int i = 0; i &lt; matrix.GetLength(0); i++)
              {
                  for (int j = 0; j &lt; matrix.GetLength(1); j++)
                  {
                      Console.Write($"\t{matrix[i, j]}\t");
                  }
                  Console.WriteLine("\n\t");
  
              }
          }
      }
  }
  </code></pre>