.Net: Supported Console Colors

.Net: Supported Console Colors

The days of writing applications that write to the console seem to be over for a while now. Notwithstanding, we find ourselves using the console from time to time to help us debug or quickly test application logic. In my case, I am currently using the console to monitor logging information from my application. It is terribly useful to be able to see progress as it happens. It sort of reminds me of using tail -f in Ubuntu against a log file. As part of my effort to make this log reading more easy I decided I wanted to color code the messages based on what they were: Errors / Warnings / Info / Debug, etc. I kept asking myself if Windows is able to support colored console as Ubuntu does, and I am happy to report it does! So here is when the question arises:

What colors are supported and how to use them?

Thankfully there is an enumeration to help us answer this question:

ConsoleColor

Member name Description
Black

The color black.

Blue

The color blue.

Cyan

The color cyan (blue-green).

DarkBlue

The color dark blue.

DarkCyan

The color dark cyan (dark blue-green).

DarkGray

The color dark gray.

DarkGreen

The color dark green.

DarkMagenta

The color dark magenta (dark purplish-red).

DarkRed

The color dark red.

DarkYellow

The color dark yellow (ochre).

Gray

The color gray.

Green

The color green.

Magenta

The color magenta (purplish-red).

Red

The color red.

White

The color white.

Yellow

The color yellow.

You may also like...

Leave a Reply

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

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