Edit scale of ALL GameObjects in an array C#

is they a way to change the scale in ALL the game objects I have stored in an array?

right now i am using this code to change one of the game objects

slots[1].gameObject.transform.localScale = new Vector3 (4,2,0.5f);

it works, but i need ALL the “slots” to change to that size but i do not know the command to do so. Also the arrays will not have the same number of element in every object that carries this script so i can not simply list all the “slots” in order.

This is very, very basic c#.

foreach(GameObject obj in slots){
    obj.gameObject.transform.localScale = new Vector3 (4,2,0.5f);
}

You can also use an index loop which is slightly more complex but does the same thing:

for(int i=0;i<slots.Length;i++)
        slots*.gameObject.transform.localScale = new Vector3 (4,2,0.5f);*

}