I have this list:
public List<List<int>> ExampleList = new List<List<int>>();
ExampleList [0].Add(0);
// Note: every list will have 4 indexes.
You may think that the list will look like this:
[0] - count: 1
+[0] - 0
[1] - null count: 0
[2] - null count: 0
[3] - null count: 0
But no, it looks like this:
[0] - count: 1
+[0] - 0
[1] - count: 1
+[0] - 0
[2] - count: 1
+[0] - 0
[3] - count: 1
+[0] - 0
The command did it for ALL the indexes.
And so I tried to do this:
public List<List<int>> ExampleList = new List<List<int>>();
public List<int> ExampleListHelper = new List<int>();
ExampleListHelper.Add(0);
ExampleList.Add(ExampleListHelper);
//Now I want to do the next index.
ExampleListHelper.Clear();
ExampleListHelper.Add(1);
ExampleList.Add(ExampleListHelper);
Not only it is very annoying, it does not work.
The index [0] of the list in [0] does not store the int 0, but the list ExampleListHelper.
meaning that after the line 4, it looked like this
[0] - count: 1
+[0] - 0
[1] - null count: 0
[2] - null count: 0
[3] - null count: 0
But after the line 7, where I changed the ExampleListHelperâs [0] index from 0 to 1, the list will look like this:
[0] - count: 1
+[0] - 1
[1] - null count: 0
[2] - null count: 0
[3] - null count: 0
Which is VERY annoying because I never touched the [0] index after line 4, but it changed on its own. And so I do this:
public List<List<int>> ExampleList = new List<List<int>>();
public List<int> ExampleListHelper0 = new List<int>();
public List<int> ExampleListHelper1 = new List<int>();
public List<int> ExampleListHelper2 = new List<int>();
public List<int> ExampleListHelper3 = new List<int>();
ExampleListHelper0.Add(0);
ExampleList.Add(ExampleListHelper0);
//Now I want to do the next index.
ExampleListHelper1.Add(1);
ExampleList.Add(ExampleListHelper1);
// I have tried with List<int>[], and it is still the same.
Then, and ONLY then, it works. But making 4 variables for one variable, and sometimes more if ExampleList has mire than 4 indexes, and if you donât plan for the ExampleList to have a max of the amount of indexes, it will be impossible.
What can I do?