I want to set the string of an index from a list that’s inside a list
So I got a variable like this:
var everyRow = new List.< List.<String> >();
My attempt at accessesing the inner List is by:
everyRow.Insert(e, List.<String>());
everyRow[e].Insert(ee, currentLog[ee]);
That line gives me this error though:
ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
So I’m guessing there’s a better way to solve this.
Help?
misher
August 29, 2017, 1:15pm
3
You nees to initialize every strings list that you want inside parent list.
So you first initialize your List of strings lists first, then you must initilalize every inner list (probably in loop).
List<List<string>> parentList = new List<List<string>>();
parentList.Add(new List<string>());
now you can add alement inside string list
parentList[0].Add("some string element");
@vultt3rim You can insert your string like this:
List<List<string>> lists = new List<List<string>>();
lists[0].Add("Hello");
string test = lists[0][0]; // Should return "Hello".
Sorry guys! It seems as though the error came up just because I had
everyRow.Insert(e, List.<String>());
inside a for loop so it kept reseting the list or something
Using Insert() or Add() works.