Spectre tables in C#
Real tables and color in a terminal, from plain C#.
using Spectre.Console;
var table = new Table().Border(TableBorder.Rounded);
table.AddColumn("language");
table.AddColumn(new TableColumn("tpm").RightAligned());
table.AddRow("csharp", "95");
table.AddRow("rust", "[bold]88[/]");
table.AddRow("python", "102");
AnsiConsole.Write(table);
AnsiConsole.MarkupLine("[green]3 rows rendered[/]");
How it works
Tablebuilds columns and rows fluently; borders are a style.- Markup like
[bold]colors inline without escape codes. AnsiConsole.Writerenders it all where plain WriteLine cannot.
Keywords and builtins used here
newusingvar
The run, in numbers
- Lines
- 12
- Characters to type
- 340
- Tokens
- 81
- Three-star pace
- 90 tpm
At the three-star pace of 90 tokens a minute, this run takes about 54 seconds.
Step 1 of 2 in Console & text, step 13 of 16 in The open ecosystem.