Advertisement
NikaBang

Контроль выхода

May 13th, 2024 (edited)
730
0
19 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. using System;
  2.  
  3. internal class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         string exitWord = "exit";
  8.         string userInput;
  9.         bool canWork = true;
  10.  
  11.         while (canWork)
  12.         {
  13.             Console.WriteLine($"Программа еще работает.\nДля завершения введите: {exitWord}.");
  14.             userInput = Console.ReadLine();
  15.  
  16.             if (userInput == exitWord)
  17.             {
  18.                 canWork = false;
  19.             }
  20.         }
  21.  
  22.         Console.WriteLine("Программа завершена.");
  23.         Console.ReadKey();
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement