如果我的程序中有很多菜单,如何在不使用任何循环的情况下返回主菜单。 假设我需要“Y”表示返回,“N”表示结束程序。
static void Main(string[] args)
{int choice;
Console.WriteLine("Main Menu");
Console.WriteLine("1. Rent");
Console.WriteLine("2. Return");
Console.WriteLine("3. Exit");
choice = Convert.ToInt32(Console.ReadLine());
while (choice!= 3)
{
if (choice ==1)
{...
//when complete all thing in choice 1
Console.WriteLine("Do you want to start over?(Y=Yes,N=No)");
// in this part i need to go back to main menu with "Y" input and close program with "N"input
}
if (choice ==2)
{...
//when complete all thing in choice 2
Console.WriteLine("Do you want to start over?(Y=Yes,N=No)");
// doing like choice 1 }