1
Answer

Deep Copying of Object

Raja Pandian

Raja Pandian

18y
4.6k
1

I have one object that's value changes at regular intervals. I want to store the object's values at each and every stage. I am storing it in an array after every stage.

ObjecstToTest[ScenarioCount] = SelectedObj;
ScenarioCount++;

The problem I face is, I am getting the array element's values are equal to the object current state. Since, I am copying the reference type, whenever the objects value changes, it changes the whole array values which are stored stored already.

I can't use serialization to store the deep copy of the object as the class I am using is not under my control. I am referencing it from a third party dll.

Please help in solving this.

Raja Pandian
Answers (1)