New to C#, can anyone explain to me how enums and setting variables for enums works? : <p>I'm sure this is a very simple question, but I'm learning how to program in C# and the "flow" of this text adventure program makes perfect sense to me, but I'm confused how  the third line "private States myState;" works. </p>

<p>As you can see, the program starts by setting the variable myState to States.cell, which calls a void method (not shown below) that waits for a key that changes the variable "myState" thus updating the update function.</p>

<p>My question is, how does the "enum" class work? It seems as though it's possible to make a variable from the "enum States" line, but I don't understand why that is. Sorry if this is a really stupid question.</p>

<p>Here's the code:</p>

<pre><code>        public Text text;
private enum States {cell, sheets_0, mirror, lock_0, sheets_1, cell_mirror, lock_1, freedom};
private States myState;

// Use this for initialization
void Start () {
    myState = States.cell;
}

// Update is called once per frame
void Update () {
    print (myState);
        if      (myState == States.cell){           state_cell();} 
        else if (myState == States.sheets_0){       state_sheets_0();} 
        else if (myState == States.mirror){         state_mirror();} 
        else if (myState == States.lock_0){         state_lock_0();} 
        else if (myState == States.sheets_1){       state_sheets_1();}
        else if (myState == States.cell_mirror){    state_cell_mirror();}
        else if (myState == States.lock_1){         state_lock_1();}
        else if (myState == States.freedom){        state_freedom();}
}
</code></pre>
