Exemplo n.º 1
0
        /// <summary>
        /// 测试原型模式,浅复制
        /// </summary>
        public static void Test()
        {
            ProductPart p = new ProductPart();
            p.Part1 = "part1";
            p.Part2 = "part2";
            ProductPart pClone = (ProductPart)p.Clone();

            Console.WriteLine(pClone.Part1);
            Console.WriteLine(pClone.Part2);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 带有属性的构造方法,可用于深复制构造
 /// </summary>
 /// <param name="id"></param>
 /// <param name="pPhoto"></param>
 public Product(string id, ProductPart pPhoto)
 {
     this.id = id;
     this.pProto = pProto;
 }