Use comma (,M) determines the field width and justification in Console.WriteLine in CSharp
Description
The following code shows how to use comma (,M) determines the field width and justification in Console.WriteLine.
Example
using System;// w w w .j av a2 s .c o m
public class TestConsoleApp
{
public static void Main(string[] args)
{
Console.WriteLine("{0,5} {1,5}", 123, 456); // Right-aligned
Console.WriteLine("{0,-5} {1,-5}", 123, 456); // Left-aligned
Console.WriteLine("{0,-10:D6} {1,-10:D6}", 123, 456);
}
}
The code above generates the following result.