how to create console application in .net core

how to create console application in .net core


1 min read

Table of contents


Tables are used to display tabular data or text on terminal. Spectre.Console is a .NET library which is used to create console applications. Spectre.Console is rendering tables and adjust all columns to fit according to prompt. Table should implement IRenderable for column header or column cell, and another table!

Create Project
>dotnet new console -o cliapp

Install nuget package
>dotnet add package Spectre.Console

Create table object

var table = new Table();

without fluent


or with fluent interface design pattern and method chaining


add columns

table.AddColumn(new TableColumn("[red3_1]C++[/]").Centered());

add rows

table.AddRow("[green]Java[/]", "[lightcyan1]D language[/]");
table.AddRow( new Panel("[deeppink2]C#[/]"));

Render table to prompt



To render a table, create a Table instance, add the number of columns according to app's requirement, and then add the rows. Complete the app by passing the table to a console's Write method.
Full source code is on github.