How to cancel the closing of the console after the actions I performed. I make a primitive calculator.
using System; class Calculator { public static void Main() { int x; //Переменная, которая задается пользователем для выбора операции. string str; //Строка, в которую будет вводиться нужная операция float result; Console.WriteLine("Введите номер операции \n 1) Сложение \n 2) Вычитание \n 3) Умножение \n 4 Деление \n Ожидание ввода:"); str = Console.ReadLine(); x = Convert.ToInt32(str); if (x == 1) { string srt1; string srt2; float x1; float x2; Console.WriteLine("Введите первое число:"); srt1 = Console.ReadLine(); x1 = Convert.ToInt32(srt1); Console.WriteLine("Введите второе число:"); srt2 = Console.ReadLine(); x2 = Convert.ToInt32(srt2); Console.WriteLine("Сумма равна:"); result = x1 + x2; Console.WriteLine(result); } else { if (x == 2) { string srt1; string srt2; float x1; float x2; Console.WriteLine("Введите первое число:"); srt1 = Console.ReadLine(); x1 = Convert.ToInt32(srt1); Console.WriteLine("Введите второе число:"); srt2 = Console.ReadLine(); x2 = Convert.ToInt32(srt2); Console.WriteLine("Произведение равно:"); result = x1 * x2; Console.WriteLine(result); } else { Console.WriteLine("Ошибка"); } } } }
Console.ReadKey();before the closing "}" functionMain. - IgorConsole.ReadLine();- Igorwhile (Console.ReadLine() != "exit") { }- Igor