# how to create console application in .net core

### Intro:-    
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**

```plaintext
table.Centered();
 table.Collapse();
table.Border(TableBorder.HeavyHead);
```

**or with fluent interface design pattern and method chaining**

```plaintext
table.Centered().Collapse().Border(TableBorder.HeavyHead);
```

**add columns**

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

**add rows**

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

**Render table to prompt**

```plaintext
AnsiConsole.Write(table);
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1674802833462/b1799402-89e7-43bd-8775-655afb76852e.png align="center")

### Conclusion:-

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.
