acidzombie24 acidzombie24 - 1 year ago 136
C# Question

copy a class, C#

Is there a way to copy a class in C#? Something like var dupe = MyClass(original).

Answer Source

Not all classes have this functionality. Probably, if a class does, it provides a Clone method. To help implement that method for your own classes there's a MemberwiseClone protected method defined in System.Object that makes a shallow copy of the current instance (i.e. fields are copied; if they are reference types, the reference will point to the original location).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download