CHAPTER 6
Enum
This chapter will discuss one of the nice features of the C# language: enumerated type or enum for short. I will show you how the enum type is defined in the .NET Framework, how you can get symbolic names and values from the enum, and how enum parses in C#.
Enum and .NET
Enum
in C# is a type, which is a set of symbolic names and values (given by you or the C# compiler) pair. For example:
public enum Planets
{
Sun = 0,
Earth,
}
Or with the explicit type:
public enum Planets : int /* int is the underlying type which C# compiler will use to set
* the values */ { ...
Get Expert C# 5.0: with the .NET 4.5 Framework now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.