Free mag vol1 | Page 210

CHAPTER 4  CORE C# PROGRAMMING CONSTRUCTS, PART II EmpType e2 = EmpType.Contractor; // These types are enums in the System namespace. DayOfWeek day = DayOfWeek.Monday; ConsoleColor cc = ConsoleColor.Gray; } EvaluateEnum(e2); EvaluateEnum(day); EvaluateEnum(cc); Console.ReadLine(); The output is shown in Figure 4-3. Figure 4-3. Dynamically discovering name/value pairs of enumeration types As you will see over the course of this text, enumerations are used extensively throughout the .NET base class libraries. For example, ADO.NET makes use of numerous enumerations to represent the state of a database connection (e.g., opened or closed) or the state of a row in a DataTable (e.g., changed, new, or detached). Therefore, when you make use of any enumeration, always remember that you are able to interact with the name/value pairs using the members of System.Enum. 145