Мне нужно выйти из цикла, но оператор goto не работает
Мне нужно выйти из цикла в моей программе и перезапустить ее с самого начала, но оператор goto не работает, после нажатия кнопки 2 программа останавливается.
вот мой код:
Что я уже пробовал:
START: //menu at the start Console.WriteLine("Welcome to Caesar Cipher Program!"); Console.WriteLine("---------------------------------"); Console.WriteLine("Please press 1 for Encyption "); Console.WriteLine("Please press 2 for Decryption "); Console.WriteLine("Please press 3 for Analysis "); Console.WriteLine("Please press 4 for About "); Console.WriteLine("Please press 5 to Exit "); int Choice = 0; Choice = Convert.ToInt32(Console.ReadLine()); string InputText; //encryption if (Convert.ToBoolean(Choice==1)) { Console.WriteLine("Please type in a text or character to encrypt: "); InputText = Console.ReadLine(); Console.WriteLine("Please input your key(integer only): "); int key; key = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Your encrypted text is : "); string EncryptedText; EncryptedText = Encrypt(InputText, key); Console.WriteLine(EncryptedText); //giving user choice to exit or restart program Console.WriteLine("Press 1 to exit or 2 to re start program! "); int choice2 = 0; if (Convert.ToBoolean(choice2==1)) { return; } if (Convert.ToBoolean(choice2==2)) { goto START; } }