use*_*693 13 c# console background colors
我搜索过网络,但似乎无法找到解决方案.我希望我的整个控制台应用程序窗口是特定的颜色,例如蓝色.我怎么做?
Han*_*ant 36
只需设置背景颜色并调用Console.Clear():
class Program {
static void Main(string[] args) {
Console.BackgroundColor = ConsoleColor.Blue;
Console.Clear();
Console.ForegroundColor = ConsoleColor.White;
Console.Write("Press any key to continue");
Console.ReadKey();
}
}
Run Code Online (Sandbox Code Playgroud)

您可以将Console.BackgroundColor属性设置为ConsoleColor枚举..
获取或设置控制台的背景颜色.要整体更改>控制台窗口的背景颜色,请设置BackgroundColor属性并调用
Clear方法.
Console.BackgroundColor = ConsoleColor.Blue;
Console.Clear();
Run Code Online (Sandbox Code Playgroud)

你可以使用Console.ForegroundColor属性
获取或设置控制台的前景色.
Console.ForegroundColor = ConsoleColor.Blue;
Run Code Online (Sandbox Code Playgroud)

OP的问题是询问如何将整个背景色设置为蓝色。其他示例均不能正确显示此内容。这是如何做:
namespace ClearConsole
{
class Program
{
static void Main(string[] args)
{
Console.BackgroundColor = ConsoleColor.Blue;
Console.Clear();
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
60130 次 |
| 最近记录: |