Use #, % and in int format
using System;
public class FormatSpecApp {
public static void Main(string[] args) {
int i = 123456;
Console.WriteLine();
Console.WriteLine("{0:#0}", i); // 123456
Console.WriteLine("{0:#0;(#0)}", i); // 123456
Console.WriteLine("{0:#0;(#0);<zero>}", i); // 123456
Console.WriteLine("{0:#%}", i); // 12345600%
i = -123456;
Console.WriteLine();
Console.WriteLine("{0:#0}", i); // -123456
Console.WriteLine("{0:#0;(#0)}", i); // (123456)
Console.WriteLine("{0:#0;(#0);<zero>}", i); // (123456)
Console.WriteLine("{0:#%}", i); // -12345600%
i = 0;
Console.WriteLine();
Console.WriteLine("{0:#0}", i); // 0
Console.WriteLine("{0:#0;(#0)}", i); // 0
Console.WriteLine("{0:#0;(#0);<zero>}", i); // <zero>
Console.WriteLine("{0:#%}", i); // %
}
}
Related examples in the same category