Exemplo n.º 1
0
        static void Main(string[] args)
        {
            IColor color = new RedColor();

            color.Red = 255;
            Console.WriteLine("color -red " + color.Red); //255
            IColor color1 = color.Clone();

            color1.Red = 224;
            Console.WriteLine("color1-red " + color1.Red); //224
            Console.WriteLine("color -red " + color.Red);  //255
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Cup cup = new Cup();

            cup.Height = 2;
            Cup cup1 = (Cup)cup.Clone();

            cup1.Height = 1;
            cup1.Factory.FactoryName = "AAA";
            Console.WriteLine(cup.Height == cup1.Height);
            Console.WriteLine(cup.Factory == cup1.Factory);


            //颜色

            IColorDemo color = new RedColor();

            color.Red = 255;

            IColorDemo color1 = color.Clone();

            color1.Blue = 255;
            Console.WriteLine(color.Blue == color1.Blue);

            IColorDemo2 color2 = new RedColor2();

            color.Red = 255;

            IColorDemo2 color3 = color2.Clone();

            color2.Blue = 252;
            Console.WriteLine(color2.Blue == color3.Blue);


            Console.ReadKey();
        }