Mega Code Archive

 
Categories / C# / Data Types
 

Format enum value

using System; enum Color {Yellow = 1, Blue, Green}; class Sample  {     public static void Main()      {     Console.WriteLine("Standard Enumeration Format Specifiers");     Console.WriteLine(         "(G) General:. . . . . . . . . {0:G}\n" +         "    (default):. . . . . . . . {0} (default = 'G')\n" +         "(F) Flags:. . . . . . . . . . {0:F} (flags or integer)\n" +         "(D) Decimal number: . . . . . {0:D}\n" +         "(X) Hexadecimal:. . . . . . . {0:X}\n",          Color.Green);            } }