C# GameObject Array

Hi, I started programming C# on Unity today, and i want a GameObject[ ] return value. So i´ve scripted this:

protected GameObject[] BuildCollidersArray()
	{
		GameObject[] gameObjectReturnees;
		Collider[] colliderList = GetCloseColliders();
		
		foreach (Collider singleCollider in colliderList) {
			if (singleCollider.gameObject.GetComponent<MagneticForces>()) {
				//~ Debug.Log("Achei um MagneticForce, name: "+singleCollider.gameObject.name);
				gameObjectReturnees.Push(singleCollider.gameObject);
			}
		}

		return gameObjectReturnees;
	}

Problem is in the .Push method.
I can´t use a Push in GameObject[ ]

Any ideas?

Arrays like that are a fixed size. Try using List instead. List<T> Class (System.Collections.Generic) | Microsoft Learn

List gameObjectReturnees = new List();
gameObjectReturnees.Add(singleCollider.gameObject);

Hey, that works =]

Ty XD

Never would have guessed this…
Absolutly newbie to C# ^^

It’s ok being a newbie to C#; there are a bazillion resources and tutorials on it!