Our enum type ServerState has an underlying int type.
The possible values for ServerState are defined as constants. The special feature Enum generates successive constant values automatically; in this case 0, 1, 2 and so on.
By implementing the ToString method, values of ServerState can be printed out or converted to strings.
If we have a value of type Integer, we cannot pass it to Transition - the compiler will complain about type mismatch. This provides some degree of compile-time type safety for enums.
Transition emulates a state transition for a server; it takes the existing state and returns a new state.
To run the program, put the code in Enums.vb and use vbc to compile it.
This example illustrates the use of enums by creating a simple state transition mechanism for a server. By defining an enum type and using a Dictionary to map enum values to strings, we can easily print out meaningful representations of the states.