Skip to content

Instantly share code, notes, and snippets.

@Zepheus
Created December 6, 2013 15:14
Show Gist options
  • Save Zepheus/7826270 to your computer and use it in GitHub Desktop.
Save Zepheus/7826270 to your computer and use it in GitHub Desktop.
Prints the lines in a fancy table.
static void PrintFrame(string[] args)
{
var maxLen = args.Select(s => s.Trim().Length).Max();
for (var i = 0; i < maxLen + 4; ++i)
Console.Write("*");
Console.WriteLine();
var center = maxLen / 2;
foreach (var s in args)
{
Console.Write("* ");
var padding = center - (s.Length / 2);
for (var i = 0; i < padding; ++i)
Console.Write(" ");
Console.Write(s.Trim());
padding = s.Length % 2 == 0 ? padding : padding - 1;
for (var i = 0; i < padding; ++i)
Console.Write(" ");
Console.WriteLine(" *");
}
for (var i = 0; i < maxLen + 4; ++i)
Console.Write("*");
Console.WriteLine();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment