Mega Code Archive

 
Categories / C# / Data Types
 

The comma (,M) determines the field width and justification

using System; 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);     } }