0

I know I can Deep Copy by accessing one property at a time and copying it. But is there a way where I can deep copy an entire object on one go? Assume I cannot alter the class Sample.

 Class Sample{
  int a;
  int b;
  public int A {get => A; set => A = value}
  public int B {get => B; set => B = value}
 }


Sample sm1 = new Sample();
Sample sm2 = sm1;
sm2.A = 5;
sm1 = sm2 //DeepCopy 
Reshma Suresh
  • 165
  • 1
  • 4
  • 13

0 Answers0