List<List<int>> help fast please

Hi,

I am using List<List> in my code.
Code (something like this but in more simple way):

public List<List<int>> a = new List<List<int>>();
List<int> b =  new List<int>();

b.Add(1);
b.Add(2);
b.Add(3);

a.Add(b);

Debug.Log(a[0][1]) // returns this error: ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Please help,
thanks

Apart from the second line being wrong (new List<int>() instead), this code works fine.

Something in your code is actually different. Check a.Count and a[0].Count to make sure the lists contain what you think they do.

2 Likes