The precision specifier controls the number of significant digits or zeros to the right of a decimal:
using System;
public class FormatSpecApp {
public static void Main(string[] args) {
int i = 123456;
Console.WriteLine("{0:C5}", i);
Console.WriteLine("{0:D5}", i);
Console.WriteLine("{0:E5}", i);
Console.WriteLine("{0:F5}", i);
Console.WriteLine("{0:G5}", i);
Console.WriteLine("{0:N5}", i);
Console.WriteLine("{0:P5}", i);
Console.WriteLine("{0:X5}", i);
}
}
Related examples in the same category