【发布时间】:2013-10-10 00:29:25
【问题描述】:
我正在用 C# 编写一个基于文本的小型冒险,它对所有内容都使用命令提示符,并且我正在寻找一种方法来更改输出文本的颜色。我看过的方法都没有正常工作。
【问题讨论】:
-
向我们展示您的尝试。
标签: c# cmd command prompt text-based
我正在用 C# 编写一个基于文本的小型冒险,它对所有内容都使用命令提示符,并且我正在寻找一种方法来更改输出文本的颜色。我看过的方法都没有正常工作。
【问题讨论】:
标签: c# cmd command prompt text-based
试试这个:
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("blue.");
阅读更多关于Console.ForegroundColor的信息,您还可以更改文本背景:Console.BackgroundColor
【讨论】:
Console.ForegroundColor = ConsoleColor.DarkRed;
应该可以正常工作。
【讨论】:
您要查找的是Console.BackgroundColor 和Console.ForegroundColor 属性。
例如;
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("This is blue!!");
【讨论】: