typestar

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

  1. Table builds columns and rows fluently; borders are a style.
  2. Markup like [bold] colors inline without escape codes.
  3. AnsiConsole.Write renders it all where plain WriteLine cannot.

Keywords and builtins used here

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.

Type this snippet

Step 1 of 2 in Console & text, step 13 of 16 in The open ecosystem.

← Previous Next →