Menu

keywords-enum

Will Pittenger

Used to declare Enum types. Enum types come in two form: Primitive-based and Structure-based. Both are described in the section [Enums] in full. The syntax for both is below.

Primitive-based enum types

\enum\ /Typeidentifier/
    [\extends\ /AnyPrimitiveTypeName/]
  ([EntryIdentifier [\=\ /ConstantExpressionForBaseType/]
  )

/AnyPrimitiveTypeName/ must be an existing primitive type, either provided by ASIL or a custom type and defaults to int. The custom type must be a single field structure and that field must be a primitive. /ConstantExpressionForBaseType/ must be a compiler-time constant expression that's valid for that base type.

Structure-based enum types

This structure-like types are technically reference types, but the instances is limited to the values listed with the values keyword. Each entry is an instance. Normally you'll declare a constructor and call it for each instance. That constructor will then initialize data members based on parameters you passed in the values clause of the enum type.

If you specify an extends clause, that type must be an abstract structure derived from "System.Enums.StructureBased".

\enum\ \struct\ /TypeIdentifier/
    [extends /BaseType/]
  \values\
    ' List values as needed.  For each value, you're calling a constructor declared by the type.

  ' Declare one or more constructors, fields, and other methods.

Related

Wiki: Custom operators
Wiki: Enums
Wiki: Keywords
Wiki: The basics (pun intended)
Wiki: keywords-abstract
Wiki: keywords-constructor
Wiki: keywords-extends
Wiki: keywords-final
Wiki: keywords-null
Wiki: keywords-union
Wiki: keywords-values