0

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

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by aayush2687
0

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")
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.