How to get a List<> from GetComponents?

GetComponents returns a . Is there any one-liner way to convert that to a Generic (List or whatever)?

I always forget this, end up landing here, and loose time to search elsewhere, so I leave this for future myself :wink:

List<Collider> collidersToTurnOff = new List<Collider>();

void Awake()

With LINQ (requires using System.Linq;):

var list = GetComponents<SomeComponent>().ToList();

Without LINQ:

var list = new List<SomeComponent>(GetComponents<SomeComponent>());

Code in C#.

List list = obj.GetComponents().Cast().ToList();

Should work, otherwise you could write your own function to do it for you.

for(int i = 0; i < arr.Length; ++i)