The body of an enumeration type declaration defines zero or more enumeration members, which are the named constants of the enumeration type. No two enumeration members can have the same name.
enum-member-declarations:
enum-member-declaration
enum-member-declarations , enum-member-declaration
enum-member-declaration:
attributesopt identifier
attributesopt identifier = constant-expression
attributesopt identifier = expression
Each enumeration member has an associated constant value. The type of this value is the base enumeration type. Multiple enumeration members may share the same associated value.
The associated value of an enumeration member is assigned either implicitly or explicitly. If the declaration of the enumeration member has a constant expression assignment, the value of that constant expression is the associated value of the enumeration member. If the declaration of the enumeration member has an expression assignment, the value of that expression is the associated value of the enumeration member. An expression can consist of elements of the current enumeration, elements of other enumerations or some constant values of the integer type.
Otherwise, the associated value is set implicitly, as follows:
The associated value of the first enumeration member is zero.
The associated value of other enumeration members is obtained by increasing the associated value of the preceding enumeration member by one.
Enum Weekday
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 permission")]
Read = 1,
[ElementAccess("Write permission")]
Write = 2,
[ElementAccess("Permission to insert records)]
Insert = 4,
[ElementAccess("Permission to delete records")]
Delete = 8,
[ElementAccess("All access permissions")]
All = Read + Write + Insert + Delete
End Enum;
See also: