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.

  1. 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?

  1. ‘List’ also works in a same manner. For instance,

List myList = new List();
for(int i = 0;i < 10;i++){
List myNewList = myList;
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?

Hi Andrew,

In general, there are ValueTypes and ReferenceTypes in C#.

A Class is a Reference Type - meaning, it operates on the same / original object passed.Your initial statement regarding why classes have Duplicate() is valid. Sometimes, we require a fresh copy of the object, and these methods do come in handy.

List, is also a Class so, it operates on the same object, unless copied / cloned / duplicated.

Note that the types, Point3d, Line, Plane, etc. are all Structs. So, assigning the ‘objects’ of a Struct automatically creates a copy and doesn’t require for a separate method.
You might find this link useful.


~ ~ ~ ~ ~ ~ ~ ~
Kaushik LS
Chennai, IN

1 Like