Cloning Types

Participants

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/636af3e0-6a76-4014-bd4c-9b6ee9b1bbf2/Untitled.png

var mainModel = new Model
{
	Data = 1
};
var copyModel = mainModel.Clone() as Model;

public interface ICloneableModel
{
	ICloneableModel Clone();
}

public class Model : ICloneableModel
{
	public int Data { get; set; }

	public ICloneableModel Clone() => MemberwiseClone() as ICloneableModel;
}

Rules of Thumb