how to set an array length?

hello everyone, so i got the following arrays:

	public GameObject[] planets;
	public Vector3[] planetsPos;

they are part of a scritp that is supposed to spawn a random amount of planets around a sun, these guys wont work unless i manualy input their, size and since the value is random it becomes imposible. if someone knows how to set their length to the size of the planets (which would me stored in a variable) please tell me.

thanks a lot.

You can either re-initialize the array like @Scribe mentioned. Or you can use the Array class’s Resize static generic method.

Array.Resize(ref planets, newSize);

@Sarper-Soher Excellent… There are always surprises in this programming… LOL
I suppose one can never know all the tools there are available.
Used your example. Worked perfect. Thanks!!!