Here's my problem. I have an object of class V with all of the properties populated. I need to generate a series of this V object, where certain properties (like 'date') are incremented from the last instance created. Because I need to increment from the last one, I created preV and load it with the already incremented newV at the bottom of the loop. Then at the top of the loop, I load the new instance of myV with preV so the date is increment from the last instance.
Because objects are reference types, when I increment the current instance of newV, all in the instances already in the list myVL show same the new value for the property.
BTW, the original instance is added manually before this ProcessV(). And the list is initialized previously.
public List<V> ProcessV(Config myConfig)
var preV = myV;
for (int i = 1; i < myConfig.Iterations; i++)
V newV = new V();
newV = preV;
// increment the date
// set preV to newV so the next iteration increment last value
preV = newV;
Would changing from a List to a Dictionary with a unique key for each do what I need?