Format integer with 3 digits and leading zeros
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
int[] numbers = { -111, 0, 169, 11111 };
foreach (int number in numbers) {
// Display value with 3 digits and leading zeros.
Console.Write("{0,11:D3}", number);
}
}
}
// -111 000 169 11111
Related examples in the same category