Thanks for raising this. I’ve implemented it for the next release.
The enum-to-integer direction was already supported using Integer(...). The missing reverse conversion is now available as a checked cast using the enum type:
Var rawStatus As Integer = Integer(HttpStatus.OK)
Var status As HttpStatus = HttpStatus(rawStatus)
Integer-to-enum conversion only accepts values declared by the enum. Invalid constants are caught during compilation, while invalid values encountered at runtime raise TypeMismatchException.
This also supports explicit, sparse, negative, and aliased values, along with built-in and qualified enum types. Converting deliberately between different enum types requires both conversions to be explicit:
Var destination As DestinationEnum = DestinationEnum(Integer(source))
You can follow the completed feature here: Support checked conversion from Integer to enumeration values.