C#. Change one character color in a sentence

Viewed 285

How can I change the color of characters? I want A and B and C to become blue.

Console.Write("Choose between, A or B or C : ");

The only way I found online was Console.ForegroundColor = ConsoleColor.Blue, but I only need A B C to be blue, not the whole sentence.

1 Answers

Set the color than write what you want to have in that color and reset the color and write what you want to have in the recent color.

ConsoleColor recentForegroundColor = Console.ForegroundColor;
Console.Write("Choose between, ");
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("A");
Console.ForegroundColor = recentForegroundColor;
Console.Write(" or ");
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("B");
Console.ForegroundColor = recentForegroundColor;
Console.Write(" or ");
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("C");
Console.ForegroundColor = recentForegroundColor;
Console.Write(" : ");
Related