Change Text Color On A C# Console App

Changing the color of the text in a C# console app can be done very easily using a built in command. The wording to this can get a little confusing and will likely be what throws you off at first, but here is how the change text color on a C# console app very easily.

Create a console app and use the standard Console.Write(“”); to output some text. This will output white text on a black background. If you would like to output some colored text then you can use the Console.ForegroundColor property. I feel this wording is a little confusing, but ForegroundColor is what we use to alter the color of the text in a command shell window.

The following command will output red and blue text similar to what you can see in the main image for this post.

            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("RED = ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write(redScore + "\n");
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.Write("BLUE = ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write(blueScore + "\n");

Similar code can also be used to change the background color of the console window using Console.BackgroundColor. It is worth exploring all of the other things that can be done using the Console object in C#. If you are using Visual Studio you can use the IntelliSense to see what options you can use. Alternatively you could also read it up in the official documentation for the Console object.

Related Articles

Related Questions

Help with RDR2 Graphics Glitches

I've been experiencing some pretty frustrating graphics glitches in Red Dead Redemption 2. As I get closer to certain objects, they flicker, and I...

How to Start Learning about Virtual Machines and Language Design?

Hey everyone! I'm diving into the world of virtual machines, specifically stack-based and register-based types. My goal is to build one from the ground...

Help! My Work PC Keeps Crashing After a Windows Update

Hey everyone! I built my first Windows PC back in February last year. It's a pretty high-end setup with a 14900K processor and a...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Tools

OpenAI Token Calculator

This tool is a simple OpenAI token calculator, web-based utility designed to help you quickly estimate the number of tokens in your text when...

List Sorting Tool

Welcome to our innovative list ordering and management tool. This next-level platform enables you to sort a list of items in ascending or descending...

Sudoku Solver

Welcome to our free online Sudoku solving tool, an interactive platform for puzzle enthusiasts seeking a break from a Sudoku conundrum. This advanced platform...

Apply Image Filters To Image

Digital imagery in the modern world is all about reinforcing emotions and stories behind each photo we take. To amplify this storytelling, we are...

Add Watermark To Image

As the world is increasingly consumed by digital media, protecting your original images is paramount. We are thrilled to introduce you to our innovative...

CSV To Xml Converter

Welcome to our CSV to XML converter tool, a convenient and user-friendly solution for all your data conversion needs. This versatile tool on our...

Latest Posts

Latest Questions