Change C# Console Text Color

In this blog post, I will show you how to change the text color of a C# console application output to the screen.

Default

By default the text color of any output is white and sometimes you might need to change the color.

The code below will ask for input first, once the input is received the input only will be printed to the screen in red. In the last line of the code, we resting the console text color for new outputs back to white(default).

using System;

Console.Write ("Type input:");
String myinput = Console.ReadLine();

Console.Write("You typed: ");
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine (myinput);
Console.ResetColor();
Published
Categorized as C#, C# 9

Leave a comment

Your email address will not be published. Required fields are marked *