如何在 C# 控制台中更改文本的背景颜色
csharpserver side programmingprogramming更新于 2025/5/25 8:52:17
要更改控制台中文本的背景颜色,请使用 C# 中的 Console.BackgroundColor 属性。
示例
现在让我们看一个例子 −
using System;
class Demo {
public static void Main (string[] args) {
Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine("Background color changed = "+Console.BackgroundColor);
}
}
输出
这将产生以下输出 −


