I am a bit new to these two methods of copying one object into the other. I am confused and unable to spot out the major difference between deep copy and shallow copy.. I ha
It's a shallow copy because if you modify the variable of ob2 - and then try and print ob1 - they will be the same. This is because things in C# that are classes create links between themselves. If you want to do a deep copy, you should implement a copy method and copy the fields by hand. Something like:
class A
{
public int a = 0;
public void display()
{
Console.WriteLine("The value of a is " + a);
}
public A Copy()
{
A a = new A();
a.a = = this.a;
return a;
}
}