March 2004
Intermediate to advanced
560 pages
26h 47m
English
The following example demonstrates the use of two types of enumerations, one with the Flags attribute applied and one without. It is fair to say, however, that use of the attribute is a little contrived in this sample.
using System; namespace Samples { public class EnumToString { enum DayOfWeek {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}; [Flags] enum MonthOfYear {January = 0x1, February = 0x2, March = 0x4, April = 0x8, May = 0x10, June = 0x20, July = 0x40, August = 0x80, September = 0x100, Ocotber = 0x200, November = 0x400, December = 0x800}; public static void Main() { string[] f = {"D", "F", "X", "G"}; DayOfWeek d = DayOfWeek.Saturday; foreach(string s in f) Console.WriteLine( "Value {0} formatted with {1}: {2}", ...Read now
Unlock full access