EasyConsole is a library to make it easier for developers to build a simple menu interface for a .NET console application.
Switch branches/tags
Nothing to show
Clone or download
splttingatms Merge pull request #2 from tjackadams/program-updates
Changed base Program class to be abstract.
Latest commit 6c8eab7 Feb 20, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
Demo added ability to prompt user for enumerated types May 9, 2016
EasyConsole Changed Program to be abstract. Feb 17, 2017
.gitattributes initial commit of project May 6, 2016
.gitignore Created nuget package May 6, 2016
EasyConsole.sln initial commit of project May 6, 2016
LICENSE Initial commit May 6, 2016
README.md Update README.md with examples May 10, 2016


EasyConsole NuGet

EasyConsole is a library to make it easier for developers to build a simple menu interface for a .NET console application.

Program Demo


  • Automatically numbered menus
  • Fluent creation of menus
  • Input/Output helpers

Quick Start


The base functionality of the library is to provide an easy way to create console menus. A Menu consists of Options that will be presented to a user for selection. An option contains a name, that will be displayed to the user, and a callback function to invoke if the user selects the option. Render the menu in the console using the Display() method.

var menu = new EasyConsole.Menu()
      .Add("foo", () => Console.WriteLine("foo selected"))
      .Add("bar", () => Console.WriteLine("bar selected"));

Menu Demo

Utilities - Input/Output

EasyConsole also provides input and output utilities to abstract the concept of dealing with the Console.

The Output class adds helper methods to control the color of text in the console.

Output.WriteLine(ConsoleColor.Red, "red");
Output.WriteLine(ConsoleColor.Green, "green");
Output.WriteLine(ConsoleColor.Blue, "blue");

Output Utility Demo

The Input class adds helper methods that prompt the user for input. The utility takes care of displaying prompt text and handling parsing logic. For example, non-numeric input will be rejected by ReadInt() and the user will be re-prompted.

object input = Input.ReadString("Please enter a string:");
Output.WriteLine("You wrote: {0}", input);

input = Input.ReadInt("Please enter an integer (between 1 and 10):", min: 1, max: 10);
Output.WriteLine("You wrote: {0}", input);

Input Utility Demo


All of these features can be put together to create complex programs with nested menus. A console program consists of a main Program class that contains Pages. The Program class is a navigator of pages and will keep a history of pages that a user is navigating through. Think of it as your browser history. To create a program you must subclass the Program class and add any Pages in the constructor. Note: Before exiting the constructor, you must set one of the pages as the main page where the program should start.

class DemoProgram : Program
    public DemoProgram()
        : base("EasyConsole Demo", breadcrumbHeader: true)
        AddPage(new MainPage(this));
        AddPage(new Page1(this));
        AddPage(new Page1A(this));
        AddPage(new Page1B(this));
        AddPage(new Page2(this));


A Page can display any type of data, but the subclass MenuPage was created to speed up the creation of pages that display menus. Simply pass in all of the options you want displayed into the options parameter in the constructor.

class MainPage : MenuPage
    public MainPage(Program program)
        : base("Main Page", program,
              new Option("Page 1", () => program.NavigateTo<Page1>()),
              new Option("Page 2", () => program.NavigateTo<Page2>()),
              new Option("Input", () => program.NavigateTo<InputPage>()))

As you can see, navigation is handled by the Program class. As you navigate through to different pages, the history is logged. You can then invoke NavigateBack() if you would like to go back to the previous page.

Example Project

The source code contains an example console demo under the Demo directory. It offers a demo with nested menu options as well as an example of how to prompt the user for input.