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

image_pdfimage_print
   
  

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);

    }
}

   
     


This entry was posted in Data Types. Bookmark the permalink.