예제 #1
0
        public object Clone()
        {
            ClassC ObjC = new ClassC();

            ObjC.valueC       = this.valueC;
            ObjC.EmbedObjectB = (this.EmbedObjectB as ICloneable).Clone() as ClassB;
            return(ObjC);
        }
예제 #2
0
        static void Main(string[] args)
        {
            ClassA ObjA = new ClassA();
            ClassB ObjB = new ClassB();
            ClassC ObjC = new ClassC();

            ObjA.EmbedObjectC = new ClassC();
            ObjB.EmbedObjectA = new ClassA();
            ObjC.EmbedObjectB = new ClassB();
            ClassA OtherA;
            ClassB OtherB;
            ClassC OtherC;

            OtherA = (ObjA as ICloneable).Clone() as ClassA;
            OtherB = (ObjB as ICloneable).Clone() as ClassB;
            OtherC = (ObjC as ICloneable).Clone() as ClassC;
            Console.WriteLine(ObjA.EmbedObjectC == OtherA.EmbedObjectC);
            Console.WriteLine(ObjB.EmbedObjectA == OtherB.EmbedObjectA);
            Console.WriteLine(ObjC.EmbedObjectB == OtherC.EmbedObjectB);
        }