NJ  Bhanushali

NJ Bhanushali

  • NA
  • 13
  • 15.6k

I have 2 object of same class as following in c#.

Jul 24 2015 2:32 AM
Myclass obj1=new Myclass(); 
Myclass obj2=null;
obj2
=obj1;
obj1
.Name="abc"; //"abc" will also assign to obj2.Name.

When I assign obj1.Name="abc", it will also assign to obj2.Name. I want to stop this. I have tried by const, sealed but I am not getting result. Can anybody suggest me how to stop reference of obj1 on obj2?


Answers (2)