C# Using colors in console , how to store in a simplified notation

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-04-23T10:58:42Z Indexed on 2010/04/23 11:03 UTC
Read the original article Hit count: 182

Filed under:

Hello,

The code below shows a line in different colors.
But thats alot of code to type just for one line and to repeat that all over a program again.
How exactly can i simplify this , so i dont need to write the same amount of code over and over?

        Console.ForegroundColor = ConsoleColor.Cyan;
        Console.Write(">>> Order: ");
        Console.ResetColor();
        Console.Write("Data");
        Console.ForegroundColor = ConsoleColor.DarkGreen;
        Console.Write("Parity");
        Console.ForegroundColor = ConsoleColor.Cyan;
        Console.Write(" <<<");

Is there any way to store ... = Console.ForegroundColor = ConsoleColor.Cyan; ?

"text" + color? + "text"; etc...

Any input appreciated regards.

© Stack Overflow or respective owner

Related posts about c#