【发布时间】:2011-11-23 08:31:39
【问题描述】:
在 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
现在,使用上面的代码,它确实将文本变为蓝色,但它只是将文本的背景变为白色,而不是整个控制台窗口的背景。
这是我的意思的一个例子:
如您所见,白色背景只显示在文本后面,并不会改变整个控制台窗口的颜色。
如何更改整个控制台窗口的颜色?
【问题讨论】:
-
鉴于这个问题比假设的重复问题旧,而且这个问题有一个可接受的答案,但新问题没有,我不同意这个断言。我已经关闭了Change Background color on C# console application 作为这个的副本。但这个问题应该保持开放。
标签: c# colors background console