Skip to content

Instantly share code, notes, and snippets.

@faxich58-gif
Last active November 30, 2025 00:47
Show Gist options
  • Select an option

  • Save faxich58-gif/c32fc875589db1e3ca7e138bcec09df5 to your computer and use it in GitHub Desktop.

Select an option

Save faxich58-gif/c32fc875589db1e3ca7e138bcec09df5 to your computer and use it in GitHub Desktop.
homeWorkCycle5
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace homeWorkCycle5
{
internal class Program
{
static void Main(string[] args)
{
const string redText = "1";
const string blueText = "2";
const string randomValue = "3";
const string clear = "4";
const string Exit = "5";
bool canExit = false;
Random rand = new Random();
int valueForRandom;
Console.WriteLine("Список команд:\n1-вывод красного текста\n2-вывод синего текста\n3-вывод случайного числа" +
"\n4-очистить консоль\n5-выход");
string commandNumber = Console.ReadLine();
switch (commandNumber)
{
case redText:
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(" Красный текст");
break;
case blueText:
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("Cиний текст");
break;
case randomValue:
Console.WriteLine(valueForRandom = rand.Next());
break;
case clear:
Console.Clear();
break;
case Exit:
canExit = true;
break;
default:
Console.WriteLine("Такой команды нет");
break;
}
if (canExit == true)
{
Console.Clear();
Console.WriteLine("Вы вышли из программы.");
}
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment