Essential Types C# Book

Format string Meaning Notes
G or g General Default
F or f Treat as though Flags attribute were present Works on combined members even if enum has no Flags attribute
D or d Decimal value Retrieves underlying integral value
X or x Hexadecimal value Retrieves underlying integral value
using System;
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
Console.WriteLine(System.ConsoleColor.Red.ToString("X"));
}
}
The output:
0000000C