I know a very old thread, but the proposed solution was not fully automatic when there are longer lines.
Therefore, I created a small helper method that makes it fully automatic. Just go to the list of string array, where each array represents a string and each element in the array, as well as a string element.
The method can be used as follows:
var lines = new List<string[]>(); lines.Add(new[] { "What", "Before", "After"}); lines.Add(new[] { "Name:", name1, name2}); lines.Add(new[] { "City:", city1, city2}); lines.Add(new[] { "Zip:", zip1, zip2}); lines.Add(new[] { "Street:", street1, street2}); var output = ConsoleUtility.PadElementsInLines(lines, 3);
The helper method is as follows:
public static class ConsoleUtility {
Hope this helps someone. Source from a post on my blog: http://dev.flauschig.ch/wordpress/?p=387
Roemer Dec 10 '14 at 11:13 2014-12-10 11:13
source share