Declare a list without initialize it.

What limitations there are between

List<float> quantityRow = new List<float>();
List<float> quantityRow;

You cant use uninitialized Lists.

1 Like

I can for example add to uninitialized list .

Example code please, because ‘no’ you cannot add elements to an uninitialized list.

public List<float> testfloat;

void Start()
{
      testfloat.Add(1f);
      Debug.Log(testfloat[0]);
}

public members of MonoBehaviour derivatives are automatically initialized by Unity so that they can be manipulated in the Inspector.

1 Like

Aha ! That is why I can use the variable…Thank you !

Normally, just doing “List someList” means someList is null. If you have private variables or non-Monobehavior classes or anything, it will be null. As Kelso said, the only exception is public variables in MonoBehaviors where Unity automatically does the “= new List()” part for you.