C#中,控制台具有可用于更改控制台背景颜色和控制台前景(文本)颜色的属性。
Console.BackgroundColor // the background color
Console.ForegroundColor // the foreground/text color
问题在于背景颜色仅适用于文本书写的区域,而不适用于空白处。Console.BackgroundColor = ConsoleColor.White; // background color is white
Console.ForegroundColor = ConsoleColor.Blue; // text color is blue
使用上述代码确实可以将文本变为蓝色,但它只会将文本的背景变为白色,而不是整个控制台窗口的背景。
以下是我的意思举例:
如您所见,白色背景只显示在文本后面,并未改变整个控制台窗口的颜色。
如何改变整个控制台窗口的颜色?