# Enum

[MSDN reference](https://msdn.microsoft.com/en-us/library/sbbt4032.aspx)

The **enum** keyword is used to declare an **enumeration,** a distinct type that consists of a **set of named** **constants** called the enumerator list.

`public enum Weekdays {monday, tuesday, wednesday, thursday, friday};`

Enumerations are useful when designing state-based programs because we can define meaningful states labels and we can use those names in our program to in our control statements to test and query the the active state.

```cpp
public enum GameStates {start, game, win, lose, end};
private GameStates activeState;  //variable to hold active state

void start(){
    activeState = GameStates.start;  //set one state as active
}


void update(){
    if(activeState == GameStates.start){
        Debug.Log( activeState.ToString() );  //this allows us to print out the labeled name, otherwise we'd see the integer value of the state: 0;
    }
   }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kdoore.gitbook.io/cs2335/f20_bkup_v2/c-language/c_language/enumerations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
