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

Should I Drive 4+ Hours for This Computer Build?

I'm considering making a 4+ hour drive with my brother to get a computer build bundle that includes an AMD Ryzen 7 7700X, Gigabyte...

Why Can’t I Access BIOS After Building My PC?

I've just put together a new PC, and while everything powers up and I do get a display, I'm unable to enter the BIOS....

Adjusting to Windows 11 After Years on macOS: Need Some Tips!

Hey everyone! I've recently switched from a MacBook after 14 years and I'm now using a new HP laptop with Windows 11. The setup...

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

Online Hash Generator – String to Hash Converter

Need to quickly generate a hash from a string? Whether you're verifying file integrity, securing data, or just experimenting with cryptographic tools, this simple...

Convert CSV To HTML Table

Need to quickly turn CSV data into an HTML table? Whether you're copying data from Excel, Google Sheets, or another spreadsheet, this tool makes...

Student Group Randomizer

Creating fair and balanced groups in the classroom can be time-consuming — especially when you're trying to avoid repetition, manage different skill levels, or...

Random Group Generator

Need to split a list of people, items, or ideas into random groups? Our free Random Group Generator makes it quick and easy. Whether...

Flip Text Upside Down – Free Online Tool

Ever wanted to flip your text upside down just for fun or to grab someone’s attention in a creative way? This free online Upside...

Raffle Ticket Generator

If you're running a fundraiser, charity draw, or local event and need raffle tickets fast, this free online tool lets you generate and print...

Latest Posts

Latest Questions