acidzombie24 acidzombie24 - 1 month ago 5
C# Question

copy a class, C#

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


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).