Is it possible to store variables in arrays?

I am currently trying to figure out how to store 5 variables in a array. I have my arrays size as 4 but its not letting me put variables in. I have my games so that the user picks 5 heroes and then that script saves that heroes data/gameobject to the variable. These are 2 different scripts as well so is it possible to save data to a array that’s in another script?
I was thinking something like:

using UnityEngine;

using System.Collections;

public class HeroArraySaver : MonoBehaviour {

GameObject heroOne;

GameObject heroTwo;

GameObject heroThree;

GameObject heroFour;

GameObject heroFive;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

GameObject array = new GameObject[4];

array[0] = heroOne;

array[1] = heroTwo; 

array[2] = heroThree;

array[3] = heroFour;

array[4] = heroFive;

}
}

The reason i chose GameObject is because a GameObject will be saved to these variables.

Your code is valid C# code, however the Length of the Array is invalid. While C# arrays are 0 based index, when you initialize an Array you are supplying the Array size as the parameter. When I use the below code everything is valid in a new test game.

void Update()
    {
        GameObject[] array = new GameObject[5];
        array[0] = heroOne;
        array[1] = heroTwo;
        array[2] = heroThree;
        array[3] = heroFour;
        array[4] = heroFive;

    }

One observation is that you are creating a new Array on each frame, you should be careful about this, since the garbage collector will have alot of work ahead of it.