[C#]
Console.WriteLine("-------------------------------");
Console.WriteLine("First Name | Last Name | Age");
Console.WriteLine("-------------------------------");
Console.WriteLine($"{"Bill",-10} | {"Gates",-10} | {51,5}");
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("-------------------------------");
Output string:
-------------------------------
First Name | Last Name | Age
-------------------------------
Bill | Gates | 51
Edna | Parker | 114
Johnny | Depp | 44
-------------------------------
如果里面有中文, 对齐就不好看了
-------------------------------
First Name | Last Name | Age
-------------------------------
盥洗区明亮 | Gates | 51
Edna | Parker | 114
Johnny | Depp | 44
-------------------------------
标签:空格,Console,Name,10,C#,-------------------------------,WriteLine,对齐
From: https://www.cnblogs.com/densen2014/p/17777938.html