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

What’s the Best Way to Configure My Case and CPU Fans for Optimal Cooling?

I've noticed that my PC is running hot lately, which is causing some stuttering while gaming. I'm wondering how I should set up my...

Best Distro for a Self-Hosted File Storage and Media Center?

I'm planning to set up a simple server where I can store my data and use it as a private streaming service. I was...

Help! I’m the Only IT Manager at a Startup and Feeling Overwhelmed

Hey everyone! I just got hired as the IT manager at a startup, and I'm starting to feel like I've walked into a bit...

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