Linqpad's Console does not honor column spacing from String.Format()
Consider the code shown here:
I stole this example from http://www.csharp-examples.net/align-string-with-spaces/
In Visual studio, these would be formatted as text columns. But in linqpad, this does not work correctly. It appears to be because each character does not get the same amount of space in the console. E.G. a non monospaced font.
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("-------------------------------");
Console.WriteLine("First Name | Last Name | Age");
Console.WriteLine("-------------------------------");
Console.WriteLine(String.Format("{0,-10} | {1,-10} | {2,5}", "Bill", "Gates", 51));
Console.WriteLine(String.Format("{0,-10} | {1,-10} | {2,5}", "Edna", "Parker", 114));
Console.WriteLine(String.Format("{0,-10} | {1,-10} | {2,5}", "Johnny", "Depp", 44));
Console.WriteLine("-------------------------------");
Console.ReadKey();
}
}
}
I stole this example from http://www.csharp-examples.net/align-string-with-spaces/
Comments
Note that the result panel is a richt text window and not a console. If you want to run console applications, you can execute the .linq file using lprun.exe (part of LINQPad):