Как изменить цвет текста переднего плана и фона в консоли? - PullRequest
6 голосов
/ 28 июля 2011

Я пишу консольную программу на C #. Я хотел бы изменить основной и цвет фона текста в консоли.

Ответы [ 4 ]

10 голосов
/ 28 июля 2011
Console.BackgroundColor//t set the background color for the text.
Console.ForegroundColor//to set the foreground color for the text.
Console.ResetColor();//set back the foreground color and background color to the default.
6 голосов
/ 28 июля 2011

Вам нужно только установить

Console.BackgroundColor = ConsoleColor.Blue;
Console.ForegroundColor = ConsoleColor.Red;

Читать все об этом на http://www.dotnetperls.com/console-color

5 голосов
/ 28 июля 2011
Console.ForegroundColor = ConsoleColor.Green;
Console.BackgroundColor = Console.Color.White;
2 голосов
/ 28 июля 2011

Вы должны иметь возможность использовать следующие свойства (ссылки на документацию MSDN):

Console.BackgroundColor

Console.ForegroundColor

...