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

Best Budget Tablets for Watching Movies?

Hey everyone! I'm on the hunt for a tablet to gift my dad for his birthday. His main use will be streaming movies and...

Will reinstalling Windows mess up my dual boot with Ubuntu?

Hey everyone! I'm currently using Ubuntu as my main operating system, but I'm having trouble getting DaVinci Resolve to work on Linux. Because of...

What’s the Deal with Azure and Microsoft 365?

I'm a bit puzzled about Azure and its relationship with Microsoft 365. Is Azure actually part of Microsoft 365, or is it a completely...

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