Understanding Lists & arrays

Hello,
I’d like to understand something with the various collection type over unity

If i want to have an array, containing various strings like this:
myArray[0]={“foo”,“bar”};
myArray[1]={“bar”};
myArray[3]={“foo”};

The list method seems to be fine, bu it needs to have a declared length first. But in my example we see that the various arrays does not have the same length.
What the good way to declare this kind of arrays/lists ?

http://wiki.unity3d.com/index.php/Choosing_the_right_collection_type

General Consensus based on user experience is that “Generic List” is by far the most useful for most uses in Unity.

Note that it is not the fastest and if you really need to perform multiple operations on a FIXED size LARGE collection of data, List is not always the way to go.

You describe a Jagged Array. In response to whether you can create a Jagged List, I found this

C# List of Lists was stated in the comments by @NewPath. Looking on t’internet warns to keep an eye on the amount of memory required when using List of Lists.

In C#, if it’s in method scope, you can declare as NewPath declared above. If it’s in class scope:

List<List<string>> jagList = new List<List<string>>();