Enum Format Strings

Format stringMeaningNotes
G or gGeneralDefault
F or fTreat as though Flags attribute were presentWorks on combined members even if enum has no Flags attribute
D or dDecimal valueRetrieves underlying integral value
X or xHexadecimal valueRetrieves 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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.