{{fbdoc item="title" value="ENUM"}}----
Declares an enumerated type.

{{fbdoc item="syntax"}}##
	**Enum** [//typename// [ Explicit ] ]
		//symbolname// [= //expression//] [, ...]
		...
	End Enum
##
{{fbdoc item="param"}}
	##//typename//##
		Name of the ##**Enum**##
	##//symbolname//##
		Name of the constant
	##//expression//##
		A constant expression
	##Explicit##
		Requires that symbols must be explicitly referred to by ##//typename//.//symbolname//##

{{fbdoc item="desc"}}
	##**Enum**##, short for enumeration, declares a list of symbol names that correspond to discrete values. If no initial value is given, the first item will be set to ##0##.  Each subsequent symbol has a value one more than the previous unless ##//expression//## is given.
	
	Symbols may be each on their own line, or separated on a single line by commas.
	
	An ##**Enum**## is a useful way of grouping together a set of related ##[[KeyPgConst|const]]##ants.  A symbol can be accessed like a constant, e.g: ##a = //symbolname//##.  But if the name clashes with another symbol, it must be resolved using ##//typename//.//symbolname//##.  This resolution method is always required if you make the enum ##Explicit##.
	
	A non-##Explicit## ##**Enum**## declared inside an ##[[KeyPgExternBlock|Extern ... End Extern]]## block will add its constants to the parent namespace directly, as in C, instead of acting as a namespace on its own. It disallows the ##//typename//.//symbolname//## style of access, and the constants may conflict with other symbols from the parent namespace.
	
	##**Enum**## can not contain any member procedure or member data (only symbols), but it can be included (named or unnamed) in a ##[[KeyPgType|Type]]## by having.
	
	An ##**Enum**## instance can be passed, as any user defined instance, to a procedure (including for the definition of ##[[KeyPgOverload|Overload]]##ed operators).
	The size of an ##**Enum**## instance will be always that of an ##[[KeyPgInteger|Integer]]## (no matter how many defined symbols are just declarations for the compiler assignment).

{{fbdoc item="ex"}}
	{{fbdoc item="filename" value="examples/manual/udt/enum.bas"}}%%(freebasic)
enum MyEnum
	option1 = 1
	option2
	option3
end enum

dim MyVar as MyEnum

MyVar = option1

select case MyVar
	case option1
		print "Option 1"
	case option2
		print "Option 2"
	case option3
		print "Option 3"
end select
%%
	
	You can reference formerly declared symbol names within the same enum:
	{{fbdoc item="filename" value="examples/manual/udt/enum2.bas"}}%%(freebasic)
enum MyEnum
	option1 = 1
	option2
	option3
	__
	MAX_VALUE = __ -1
end enum

print "Option #1:", MyEnum.option1
print "Option #2:", MyEnum.option2
print "Option #3:", MyEnum.option3
print "Max Value:", MyEnum.MAX_VALUE
%%	Output:
	%%
Option #1:     1
Option #2:     2
Option #3:     3
Max Value:     3
%%
{{fbdoc item="lang"}}
	- Explicit Enum not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Explicit""**##.

{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- ##[[KeyPgConst|Const]]##
	- ##[[KeyPgOperator|Operator]]##
	- ##[[TblVarTypes|Table with variable types overview, limits and suffixes]]##

{{fbdoc item="back" value="CatPgUserDefTypes|User Defined Types"}}