Advertisement
Vlad_Savitskiy

Exit Example

Jun 30th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CSLightFirst
  4. {
  5.     class Program
  6.     {
  7.         private static void Main()
  8.         {
  9.             bool isExit = false;
  10.  
  11.             while (!isExit)
  12.             {
  13.                 Console.WriteLine("Что бы Вы хотели сделать?\ndate - Показать текущую дату\ntime - Показать текущее время\nexit - Выйти из программы\n");
  14.                 Console.Write("Ваш ответ: ");
  15.                 string userInput = Console.ReadLine();
  16.                 Console.WriteLine();
  17.  
  18.                 switch (userInput)
  19.                 {
  20.                     case "date":
  21.                         Console.WriteLine($"Текущая дата: {DateTime.Today.Date}");
  22.                         break;
  23.                     case "time":
  24.                         Console.WriteLine($"Текущее время: {DateTime.Now.TimeOfDay}");
  25.                         break;
  26.                     case "exit":
  27.                         isExit = true;
  28.                         break;
  29.                 }
  30.  
  31.                 Console.WriteLine();
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement