To my humble knowledge, if a class object is directly assigned to another object, for instance,
MyClass A = new MyClass();
MyClass B = A:
A and B share same object.
That is why for instance, Rhino provides .Duplicate() method to avoid this problem. (see below)
I have 2 questions regarding this.
- Both Plane and Line are class object but do not provide such method to clone. But even without, directly assigning Point3d or Line object to another won’t share same object. (see attached image below)
why is this so? why some geometry type provides Duplicate() while others do not?
- ‘List’ also works in a same manner. For instance,
List myList = new List();
for(int i = 0;i < 10;i++){
myList.Add(i);
}
List myNewList = myList;
myNewList.RemoveAt(0);
A = myList[0];
myList and myNewList share same list and therefore A is 1. not 0.
So I use following way to create duplicate of a list.
List myList = new List();
List myNewList = new List(myList);
is this conventional way of duplicating a list? or is there another way?