문제

I'm writing a small text-based adventure in C# that uses the command prompt for everything, and I'm looking for a way to change the colour of outputted text. None of the methods I've looked at have worked properly.

도움이 되었습니까?

해결책

Console.ForegroundColor = ConsoleColor.DarkRed;

Should work fine.

다른 팁

try this:

Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("blue.");

Read more about Console.ForegroundColor you can also change background of text: Console.BackgroundColor

What you looking for is Console.BackgroundColor and Console.ForegroundColor properties.

For example;

Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("This is blue!!");

enter image description here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top