using System;
namespace ConsoleTest
{
class Program
{
static void Main(string[] args)
{
bool continueProgram = true;
while (continueProgram)
{
Console.WriteLine("数字画图帮助:0黑色,1深蓝,2深绿色,3深青色,4暗红色,5深品红色,6深黄色,7灰色,8深灰色,9蓝色,a绿色,b青色,c红色,d洋红,/ 是换行。");
Console.WriteLine("请输入数字:");
string input = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.White;
foreach (char c in input)
{
switch (c)
{
case '0':
Console.ForegroundColor = ConsoleColor.Black;
break;
case '1':
Console.ForegroundColor = ConsoleColor.DarkBlue;
break;
case '2':
Console.ForegroundColor = ConsoleColor.DarkGreen;
break;
case '3':
Console.ForegroundColor = ConsoleColor.DarkCyan;
break;
case '4':
Console.ForegroundColor = ConsoleColor.DarkRed;
break;
case '5':
Console.ForegroundColor = ConsoleColor.DarkMagenta;
break;
case '6':
Console.ForegroundColor = ConsoleColor.DarkYellow;
break;
case '7':
Console.ForegroundColor = ConsoleColor.Gray;
break;
case '8':
Console.ForegroundColor = ConsoleColor.DarkGray;
break;
case '9':
Console.ForegroundColor = ConsoleColor.Blue;
break;
case 'a':
Console.ForegroundColor = ConsoleColor.Green;
break;
case 'b':
Console.ForegroundColor = ConsoleColor.Cyan;
break;
case 'c':
Console.ForegroundColor = ConsoleColor.Red;
break;
case 'd':
Console.ForegroundColor = ConsoleColor.Magenta;
break;
case '/':
Console.WriteLine();
break;
default:
Console.WriteLine("输入的字符无效,请输入指定字符。");
break;
}
Console.Write(“■”);
}
Console.Write(“\n”);
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("要继续请输入'Y',要退出请输入'N'");
char choice = Console.ReadKey().KeyChar;
if (choice == 'N' || choice == 'n')
{
continueProgram = false;
}
}
}
}
}