Enumerations is a distinct value type that declares a set of elements. Each element is a named constant with associated value.
Each enumerated type has a corresponding integer type named a basic type of the enumerated type. An enumerated type declaration may explicitly declare a basic type: Byte, SByte, Short, UShort, Integer, UInteger, Long, ULong. The Char type cannot be used as a basic type. If a basic type is not specified, Integer is set as a default type.
The body of enumerated type must contain at least one element. No two elements can have the same name but they can have the same value. A value is assigned value of basic type. A constant value can also be formed by calculating an expression consisting of elements of the current enumeration, elements of other enumerations or integer constants.
An enumeration declaration consists of an optional set of interface attributes, followed by the optional Public or Friend access modifiers, followed by the Enum keyword and an enumeration name. Then may follow the basic type via a colon. Then follow enumeration elements and their numeric values via commas. The description ends with a sequence of End Enum keywords.
//Enumeration with access modifier and basic type
Public Enum Weekday: Byte
Monday = 1,
Tuesday = 2,
Wednesday = 4,
Thursday = 8,
Friday = 16,
Saturday = 32,
Sunday = 64
End Enum;
//Attributes and expressions in enumeration elements
Public Class ElementAccessAttribute: System.Attribute
_Description: String;
Public Constructor ElementAccessAttribute(ElementDescription: String);
Begin
_Description := ElementDescription;
End Constructor;
End Class;
Enum UserAccess
[ElementAccess("No access permissions")]
None = 0,
[ElementAccess("Read permissions")]
Read = 1,
[ElementAccess("Write permissions")]
Write = 2,
[ElementAccess("Record insert permissions")]
Insert = 4,
[ElementAccess("Record delete permissions")]
Delete = 8,
[ElementAccess("All access permissions")]
All = Read + Write + Insert + Delete
End Enum;
See also: