Click or drag to resize

NiceFormatter.Tablize Method

Converts an enumerable set of objects (of the same type) into a mock table of rows and columns formatted using ASCII box characters. Each property in the incoming object type becomes a column of the mock table. The first row of the mock table is a header row containing the column property names.

Namespace: Orthogonal.Common.Basic
Assembly: Orthogonal.Common.Basic (in Orthogonal.Common.Basic.dll) Version: 2025-03-15 14:42 GMT+11
Syntax
C#
public static IEnumerable<string> Tablize(
	this IEnumerable<Object> source,
	int? maxColLen = null,
	int? maxRows = null
)

Parameters

source  IEnumerable<Object>
An enumerable set of objects which must be the same Type.
maxColLen  Nullable<Int32>  (Optional)
Optional maximum length of text in each mock column.
maxRows  Nullable<Int32>  (Optional)
Optional maximum number of mock rows to process.

Return Value

IEnumerable<String>
An enumerable set of text lines that display as a mock table using box ASCII characters. Control characters in the displayed values are replaced with a small box U+25AB.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<Object>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Example
C#
var list = Process.GetProcesses().Take(5).Select(p => new { p.ProcessName, p.Id, p.WorkingSet64, p.BasePriority });
string[] lines = NiceFormatter.Tablize(list).ToArray();
foreach (var line in lines) Console.WriteLine(line);
Output Lines
┌─────────────┬─────┬──────────────┬──────────────┐
│ ProcessName │ Id  │ WorkingSet64 │ BasePriority │
├─────────────┼─────┼──────────────┼──────────────┤
│ Idle        │ 081920            │
│ System      │ 438952968            │
│ Registry    │ 124707133448            │
│ smss        │ 48054476811           │
│ csrss       │ 616410009613           │
│ wininit     │ 704411648013           │
└─────────────┴─────┴──────────────┴──────────────┘
See Also