I have an interesting question. Imagine I have a lot of data changing in very fast intervals. I want to display that data as a table in console app. f.ex:
-------------------------------------------------------------------------
| Column 1 | Column 2 | Column 3 | Column 4 |
-------------------------------------------------------------------------
| | | | |
| | | | |
| | | | |
-------------------------------------------------------------------------
How to keep things fast and how to fix column widths ? I know how to do that in java, but I don't how it's done in C#.
This is an improvement to a previous answer. It adds support for values with varying lengths and rows with a varying number of cells. For example:
Here is the code:
Use MarkDownLog library (you can find it on NuGet)
you can simply use the extension ToMarkdownTable() to any collection, it does all the formatting for you.
Output looks something like this:
You could do something like the following:
I wanted variable-width columns, and I didn't particularly care about the box characters. Also, I needed to print some extra information for each row.
So in case anyone else needs that, I'll save you few minutes:
Output:
It's easier in VisualBasic.net!
If you want the user to be able to manually enter data into a table:
It should look like this: