I have classes :
public class ComplexObject
{
public int number = 12;
public anotherComplexObject aco;
}
public class Experiment
{
public ComplexObject GetDeepCopyObj(ComplexObject obj)
{
var copiedData = new ComplexObject
{
number = obj.number,
aco = obj.aco
};
return copiedData ;
}
static void Main()
{
ComplexObject c1 = new ComplexObject();
c1.number = 3;
c1.aco = new anotherComplexObject{...};
Experiment experiment = new Experiment();
ComplexObject c2 = experiment.GetDeepCopyObj(c1); //line 99
}
}
Here, when i make a call to GetDeepCopyObj(c1) in "line 99", will c2 be a deep copied object of c1 in c#(aco field is reference type..Still it will have same reference right? i am assuming a deep copy will not happen here)?