Skip to content

Latest commit

 

History

History
73 lines (48 loc) · 2.08 KB

README.md

File metadata and controls

73 lines (48 loc) · 2.08 KB

Simple Console Menus

NuGet Publish NuGet

Use the up and down arrow keys to navigate and the ENTER key to select.

Simple Console Menu Example

Using

using YonatanMankovich.SimpleConsoleMenus;

Adding Menu Options

Manually

SimpleConsoleMenu menu = new SimpleConsoleMenu("Choose an option:");
menu.AddOption("Option 1").AddOption("Option 2").AddOption("Option 3");

Using params

SimpleConsoleMenu menu = new SimpleConsoleMenu("Choose an option:", "Option 1", "Option 2", "Option 3");

Using IEnumerable

IEnumerable<string> options = new List<string>() { "Option 1", "Option 2", "Option 3" };
SimpleConsoleMenu menu = new SimpleConsoleMenu("Choose an option:", options);

Getting Results

menu.Show();
int selectedIndex = menu.SelectedIndex;
string selectedItemName = menu.GetSelectedItemName();
Console.WriteLine($"You selected index {selectedIndex} which is '{selectedItemName}'");

Simple Menu


Simple Action Console Menu Example

SimpleActionConsoleMenu menu = new SimpleActionConsoleMenu("Choose an option with an action:");
menu.AddOption("Write 'Hello!'", () => Console.WriteLine("Hello!"))
    .AddOption("Show another menu", TestSimpleConsoleMenu)
    .AddOption("Exit", () => Environment.Exit(0))
    .ShowAndDoAction();

Action Menu

My Other Projects That Use This Library

Command Line Synonyms Practice Tool

Command Line Battleship Game

Command Line Snake

Command Line Minesweeper

System Specs Scraper