Formatting integers : int format « Data Type « C# / CSharp Tutorial






class MainClass
{
  public static void Main(){

    
    int myInt = 12345;
    int myInt2 = 67890;
    System.Console.WriteLine("myInt = {0, 6}, myInt2 = {1, 5}", myInt, myInt2);
    System.Console.WriteLine("myInt using 10:d = {0, 10:d}", myInt);
    System.Console.WriteLine("myInt using 10:x = {0, 10:x2}", myInt);

  }

}
myInt =  12345, myInt2 = 67890
myInt using 10:d =      12345
myInt using 10:x =       3039








2.8.int format
2.8.1.Formatting integers
2.8.2.int format: {0:C}, {0:D}, {0:E}, {0:F}, {0:G}, {0:N}, {0:P}, {0:X}