原型模式

    .net 中使用此模式只需要实现接口  ICloneable 

class Program
    {
        static void Main(string[] args)
        {
            Person p1 = new Person() { Name = "xz", Age = 1 };
            Person p2 = (Person)p1.Clone();
            p2.Name = "ww";
            p2.Age = 2;
            Console.WriteLine($"p1 {p1.Age} {p1.Name}");
            Console.WriteLine($"p2 {p2.Age} {p2.Name}");
            Console.Read();
        }

    }
    public class Person : ICloneable
    {
        public string Name { get; set; }
        public int Age { get; set; }
        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }

原文地址:https://www.cnblogs.com/student-note/p/12468014.html