// Elements of an enumeration need not be sequential!
enum EmpType
{
Manager = 10,
Grunt = 1,
Contractor = 100,
VicePresident = 9
}
Controlling the Underlying Storage for an Enum
By default, the storage type used to hold the values of an enumeration is a System.Int32 (the C#
int); however, you are free to change this to your liking. C# enumerations can be defined in a simi-
lar manner for any of the core system types (byte, short, int, or long). For example, if you want to
set the underlying storage value of EmpType to be a byte rather than an int, you can write the
following:
C H A P T E R 4
■
C O R E C # P R O G R A M M I N G C O N S T R U C T S, PA RT I I
121
8849CH04.qxd 10/1/07 10:31 AM Page 121
Do'stlaringiz bilan baham: |