Writing a small command line tool, it would be nice to output in different colours. Is this possible?
+7
A:
class Program
{
static void Main()
{
Console.BackgroundColor = ConsoleColor.Blue;
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("White on blue.");
Console.WriteLine("Another line.");
Console.ResetColor();
}
}
Taken from here.
Darin Dimitrov
2010-04-30 08:41:26
How did I miss something so obvious, lol. Thanks very much!
SLC
2010-04-30 08:46:25
If you directly copy and paste someone else's content IMHO it is the good thing to do to link to the original source.
Mark Byers
2010-04-30 08:46:41
@Mark, I agree with you but this means every time you write a single line of code you will need to quote MSDN because chances are, it is already written in the documentation. But you are right, I should have provided a link to the site. Updating my answer.
Darin Dimitrov
2010-04-30 08:54:54
@Darin: Seen your update: Voted +1. :)
Mark Byers
2010-04-30 09:01:36
+11
A:
Yes. See this article. Here's an example from there:
Console.BackgroundColor = ConsoleColor.Blue;
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("White on blue.");
Mark Byers
2010-04-30 08:42:22