I am creating a basic program in unity where I check a list array index carry out a certain action depending on the value, I then increment the index.The problem I am having is that the array always stores in index 0 and always equals -1. 

```
    public class numGen(){  
    int val;
    int i = 0;

    System.Random rnd = new System.Random();
        val = rnd.Next(1, 5);
        arrayList.Add(val);

        Debug.Log("val"+val);
        Debug.Log("array"+arrayList.IndexOf(i));

        if (arrayList.IndexOf(i) == 1)
         {
                Debug.Log("action1");
                i++;
         }
        else if (arrayList.IndexOf(i) == 2)
                {
                  Debug.Log("action2");
                  i++;
                }
           //and so on
    }

```

I have used debug in the log, so val will output a expected value, e.g. 2, gets added into the array when I check the value stored in the index it's -1. 

Not sure how or why the int value is changing.