Monday, October 16, 2006

Colour Your Console Apps

A new feature in .NET2.0 is the ability to add colour to console applications. There's now no need to use Interop to import Kernel32.dll as was previously the case. Simply use the ForegroundColor and BackgroundColor properties of the Console object to give your console apps more readability as below. Lovely !

Console.ForegroundColor = System.ConsoleColor.Cyan;
Console.BackgroundColor = System.ConsoleColor
.Magenta;
Console.WriteLine("Hello"
);
Console.ForegroundColor = System.ConsoleColor
.Magenta;
Console.BackgroundColor = System.ConsoleColor
.Cyan;
Console.WriteLine("Miles"
);
Console.ReadLine();

1 comment:

Anonymous said...

The Kernel is finger licking good.