Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Data;
- internal class Program
- {
- static void Main(string[] args)
- {
- const string CommandShowText = "1";
- const string CommandShowTime = "2";
- const string CommandShowRandomNumber = "3";
- const string CommandClearConsole = "4";
- const string CommandExit = "5";
- bool isWork = true;
- while (isWork)
- {
- Console.WriteLine($"{CommandShowText} - показать текст." +
- $"\n{CommandShowTime} - показать время." +
- $"\n{CommandShowRandomNumber} - показать случайное число." +
- $"\n{CommandClearConsole} - отчистить консоль." +
- $"\n{CommandExit} - завершить программу.");
- string userInput = Console.ReadLine();
- switch (userInput)
- {
- case CommandShowText:
- Console.WriteLine("Hello World!");
- break;
- case CommandShowTime:
- Console.WriteLine(DateTime.Now);
- break;
- case CommandShowRandomNumber:
- Random random = new Random();
- Console.WriteLine(random.Next());
- break;
- case CommandClearConsole:
- Console.Clear();
- break;
- case CommandExit:
- isWork = false;
- Console.WriteLine("Программа завершена.");
- break;
- default:
- Console.WriteLine("Ошибка ввода!");
- break;
- }
- }
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment