如何在控制台中更改前景和背景文字颜色?

kin*_*981 6 c# console colors

我正在编写一个控制台C#程序.我想在控制台中更改文本的前景色和背景色.

Jal*_*aid 10

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.
Run Code Online (Sandbox Code Playgroud)


sti*_*mms 6

你只需要设置

Console.BackgroundColor = ConsoleColor.Blue;
Console.ForegroundColor = ConsoleColor.Red;
Run Code Online (Sandbox Code Playgroud)

http://www.dotnetperls.com/console-color上阅读所有相关内容


Adi*_*dir 5

Console.ForegroundColor = ConsoleColor.Green;
Console.BackgroundColor = Console.Color.White;
Run Code Online (Sandbox Code Playgroud)