Simple int array in unity 3d

How can i create a int array in class.

And i have to add values to that array.

Not to a specific key.

i declared array as

public int[] iArray;

from function i have to insert values of i to array. i is int. My i values gets change and no specific limits. So i have to save those in a array.

iArray[] = i; 

But it shows error.

What is i here? Is it an integer value? If so, you need to assign it to a single key. If i is an integer array by itself you can re-initialize iArray everytime you want to pass values. For eg :

    iArray[] = new int[i.Length];
    
    for(int x = 0;x<i.Length;x++)
    iArray[x] = i[x];

Or if i will be a seperate value each time you are calling this function and you want to store all values of i then you will be better off using a List. Add using System.Collections.Generic; to the header and then use the following code :

List<int>    myList;

I suggest you read through the MSDN docs for lists

//Whenever you want to store value of i
myList.Add(i);