Get a GameObject from a component

I want to get a list of GameObjects that contain this script named Alpha

I then destroy that script on all those Game Objects, but want to keep the list with the Game Objects.

I do it now by Having a list of

Alpha[] aList = GetComponentsInChildren<Alpha>();

// Destroy scripts here.
foreach(Alpha a in aList)

If I didn’t destroy the scripts I know I could do


However I do have to Destroy these scripts then I want to keep pointing to the GameObject. I tried things like this but failed to compile.

GameObject[] list;

list = GetComponentsInChildren<Alpha>() as GameObject;

I would rather not have to search through the components twice nor would I like to copy the array before destroying.

I came up with this:

List<GameObject> list = new List<GameObject>();

foreach( Alpha a in GetComponentsInChildren<Alpha>() ) {
   list.Add( a.gameObject );

Basically, I see no major difference between array and List; anything you can do with an array, you can do it with a List. If you insist on using an array, then convert the List to array by adding this line:

GameObject [] objectList = list.ToArray();