Mega Code Archive

 
Categories / C# Book / 02 Essential Types
 

0299 Numeric Format Strings X or x

Letter Meaning X or x Hexadecimal using System; using System.Text; using System.Globalization; class Sample { public static void Main() { Console.WriteLine("{0:X}", 20); Console.WriteLine("{0:x}", 20); Console.WriteLine("{0:X4}", 20); } } The output: 14 14 0014 X for uppercase hex digits; x for lowercase hex digits. X or x is for integrals only.