hey guyz howz u ????
cn u tell me how cn i color my console based output( in C# ) not a whole output but a selected string only.
plz tell me if u knw d answer .......:)
Bye TC

Recommended Answers

All 2 Replies

This can be done this way:

//Save existing colors
ConsoleColor remFG = Console.ForegroundColor;
ConsoleColor remBG = Console.BackgroundColor;
//Set colors
            Console.ForegroundColor = ConsoleColor.Black;
            Console.BackgroundColor = ConsoleColor.Cyan;
//Write something
            Console.Write("This is a string in black, with cyan background");
//Restore colors
            Console.ForegroundColor = remFG;
            Console.BackgroundColor = remBG;
Console.Write("This will be in the previous colors")

Thnx alot ddanbe :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.