Click or drag to resize

NiceFormatterTablize 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: 2024-04-15 18:00 GMT+10.f27da1471008deaf16b803c17e24a5955690aef1
Syntax
C#
public static IEnumerable<string> Tablize(
	this IEnumerable<Object> source,
	int? maxColLen = null,
	int? maxRows = null
)

Parameters

source  IEnumerableObject
An enumerable set of objects which must be the same Type.
maxColLen  NullableInt32  (Optional)
Optional maximum length of text in each mock column.
maxRows  NullableInt32  (Optional)
Optional maximum number of mock rows to process.

Return Value

IEnumerableString
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 IEnumerableObject. 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