Beispiel #1
0
        static void DoSimpleClone()
        {
            // Uses the Clone method on a class with no circular references
            var obj = new SimpleClone()
            {
                A = "salam",
                B = 100
            };
            var clone = obj.Clone();

            Console.WriteLine(clone);
            Console.WriteLine("Clone equals original: " + (clone == obj));
            Console.WriteLine();
        }
Beispiel #2
0
        static void DoDeepClone()
        {
            // Uses the Clone method on a class with no circular references
            var obj = new SimpleClone()
            {
                A = "salam",
                B = 100
            };
            var deep = new DeepClone()
            {
                A      = "first",
                Simple = obj
            };
            var clone = deep.Clone();

            Console.WriteLine(clone);
            Console.WriteLine("Clone equals original: " + (clone == deep));
            Console.WriteLine();
        }