How do you initialize a List or Array?

I’d like to know how to initialize a generic list.

I have mylist=new List.<String>();

I can't put mylist[14]="hello"; //because it doesn't exist yet.  
mylist.Insert(14,"hello"); //same problem?  

Do I have to initialize the list somehow?
I tried using things I’ve seen in a search like ([1…40]) but unity doesn’t recognize them.

I can’t figure out how to initialize the list with placeholders.

Looks like your list is created, but empty.


You did initialize it; that’s what “mylist=new List.<String>();” does. To add content, use the Add function. List<T> Class (System.Collections.Generic) | Microsoft Learn