Cover image for Do you still write console applications?

Do you still write console applications?

peledzohar profile image Zohar Peled Updated on ・2 min read

I do.

Most of the times just as a POC (Proof Of Concept), to test an implementation of an algorithm, to automate some in-house operation. Admittedly, I don't recall the last time I've written a console application for a customer, though.

My point is, I find console applications to be a very helpful tool when you need to get something done fast.

tl;dr; there's a link at the bottom of the post...

However, I find the Console itself very limiting. For instance, if I want to write a line to the screen, and highlight a word or two inside, I have to write a at least 5 lines of code just for that:

Console.Write("First part of the line ");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("Highlighted in yellow ");
Console.WriteLine("The rest of the line.");

And if the current console colors are not it's default, I'll have to add more code to store the original color, and that's just for one single highlight, with only one color! If I wanted to change the background color as well, I would have to add at least one more code line, and what if I wanted to highlight two different sections of the text?

Wouldn't it be great if you could use a simple markup for that?

Well, Now you can!

After writing too many console apps I've collected a few methods and written some new one, and came up with a GitHub project I've called Extended Console.
It enables you to use a simple markup consisting a single tag - c with two optional attributes: f for foreground and b for background. The values of these attributes need to be a name of a member of the Console.Color enum, but that name is case insensitive (the tag and attributes are not!).
So instead of the massive code in the above examples, you can simply write this:

var exConsole = new ExConsole();
exConsole.WriteLine("This <c f='yellow'>is yellow</c> and this <c f='cyan' b='darkred'>and this is cyan with a Dark red background.</c> more text.");

And this is what it looks like:

Alt Text

It also contains methods for reading and parsing user input, two overloaded methods for menus, and what I think is the best part - it's super easy to extend - simply add your own extension methods.

To conclude, if like me, you still write console applications, and you want to easily add some colors, menus, or user input capabilities to them, this project is for you!

It's MIT licence so it's completely free and open source.

Check it out on GitHub.

Read more about it on my blog

This project is available on Nuget.Org as ExtendedConsole.

Posted on by:

peledzohar profile

Zohar Peled


By day, try to work. By night, try to sleep.


markdown guide

I still write console apps. For example, asmdeps (GitHub.com/fluffynuts/dotnet-utils) for diagnosing .net assembly issues. Also in that repo is a tool for finding orphaned code files, which is quite useful after merging master back into my current feature branch. The CLI is still alive! ):