Control the width and alignment in Console.WriteLine in CSharp
Description
The following code shows how to control the width and alignment in Console.WriteLine.
Example
/* www. j av a 2 s . c o m*/
using System;
public class TestConsoleApp {
public static void Main(string[] args) {
Console.WriteLine("\n{0,-10}{1,-3}", "Name", "Salary");
Console.WriteLine("{0,-10}{1,6}", "Bill", 123456);
Console.WriteLine("{0,-10}{1,6}", "Polly", 7890);
}
}
The code above generates the following result.