So i have an object of ojects like so
[["value1","value2","value3"]]
and my goal is to access these objects, and modify them, then return it to a new list containing the existing objects.
Here's what I've tried
List<dynamic> data = new List<dynamic>();
foreach(var i in objects)
{
List<dynamic> innerData = new List<dynamic>();
foreach(var j in i)
{
innerData.Add(j + " NEW");
}
data.AddRange(innerData);
}
the output isn't the same. It will return the following
[["value1 NEW"], ["value2 NEW"],["value3 NEW"]]
It returns a new list, but instead of having one object with three values inside the list, it returns three objects with one value inside the list.
My goal is to have the same output format as the input format. Like so
[["value1 NEW","value2 NEW", "value3 NEW"]]
datalist in your inner loop? Instead of adding them to a second list, and adding the list to the full list.AddRange. Try doingAdd. I'm not sure if the compiler will allow that but what you did was basically add each item in the internal collection to the main collection. And what you want is add it as a collection.Addwill achieve that