当前位置: 首页>>代码示例>>C#>>正文


C# Customer.Clone方法代码示例

本文整理汇总了C#中Customer.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.Clone方法的具体用法?C# Customer.Clone怎么用?C# Customer.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Customer的用法示例。


在下文中一共展示了Customer.Clone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    static void Main()
    {
        List<Payment> payments = new List<Payment>
        {
            new Payment("Payyy", "10 lv."),
            new Payment("Payyy2", "210 lv."),
        };

        //check 2 payments with Equals and ==
        //Payment p1 = new Payment("Payyy", "10 lv.");
        //Payment p2 = new Payment("Payyy", "10 lv.");
        //Console.WriteLine(p1.Equals(p2));
        //Console.WriteLine(p1 == p2);
        //Console.WriteLine("=================================");

        //Check 2 customer, one a clone of the other, with Equals and ==
        Customer a = new Customer("Pesho", "Ivanov", "Petrov", 1111, "Severna Koreq", "08898967674", "[email protected]", payments, CustomerType.Golden);
        //Customer b = new Customer("Pesho", "Ivanov", "Petrov", 1111, "Severna Koreq", "08898967674", "[email protected]", payments, CustomerType.Golden);
        Customer b = a.Clone() as Customer;
        Customer c = a;

        Console.WriteLine(a.Equals(b));  //da
        Console.WriteLine(a.Equals(c));  //da
        Console.WriteLine(a == b);  //ne
        c.FirstName = "blq";
        Console.WriteLine(a == c);  //da

        //CompareTo
        a.FirstName = "Pesho";
        Console.WriteLine(a.CompareTo((Customer)b)); //0
        b.FirstName = "Todor";
        Console.WriteLine(a.CompareTo((Customer)b)); //Pesho > Todor
    }
开发者ID:i-yotov,项目名称:Courses,代码行数:33,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            List<Payment> payments = new List<Payment>()
            {
                new Payment("Laptop", 999),
                new Payment("Glasses", 300),
                new Payment("Vodka", 60)
            }; 

            Customer pesho = new Customer("Pesho", "Peshev", "Peshov", "6840562897",
                "Karlukovo", "+3598888888888", "[email protected]", payments, CustomerType.Golden);

            Customer gosho = new Customer("Gosho", "Georgiev", "Goshev", "5068795469", 
                "Gorna Orqhovica", "+359878967458", "[email protected]", payments, CustomerType.Diamond);

            Console.WriteLine(pesho.CompareTo(gosho));
            Console.WriteLine(pesho.Equals(gosho));
            
            Console.WriteLine();
            Console.WriteLine(pesho);
            Console.WriteLine(pesho.GetHashCode());

            object clonedCustomer = gosho.Clone();
            Console.WriteLine(clonedCustomer.Equals(gosho));


        }
开发者ID:premiera85,项目名称:Software-University,代码行数:27,代码来源:TestCustomers.cs

示例3: Main

    static void Main()
    {
        var pesho = new Customer("Petar", "Ivanov", "Mitrev", "123456789","dolno tunkovo", "123123123","[email protected]");
        var pesho2 = new Customer("Petar", "Ivanov", "Mitrev", "123456788","dolno tunkovo","123123123123", "[email protected]");
        var gosho = new Customer("Gosho", "Ivanov", "Shopov", "100000001","na maikasi putkata","1-500-123123","[email protected]");

        Payment[] payments =
            {
                new Payment("book", 25.5m),
                new Payment("phone", 250.89m),
                new Payment("tablet", 500),
                new Payment("phone", 250.89m),
                new Payment("tablet", 500)
            };

        foreach (var payment in payments)
        {
            pesho.AddPayment(payment);
            gosho.AddPayment(payment);
        }

        var petarCloning = (Customer)pesho.Clone();
        //Console.WriteLine(gosho);
        Console.WriteLine(pesho == gosho);
        Console.WriteLine(pesho == pesho2);
        Console.WriteLine(pesho == petarCloning);

        Console.WriteLine(pesho.CompareTo(gosho));
        Console.WriteLine(pesho2.CompareTo(pesho));
        Console.WriteLine(pesho.CompareTo(petarCloning));

        Console.WriteLine("=------------------------------------------");

        Customer cloning = (Customer)pesho.Clone();

        pesho.Payments[0].ProductPrice = 200;
        cloning.Payments[0].ProductPrice = 100000;

        Console.WriteLine("Pesho cloninig:\n{0}", cloning.Payments[0].ProductPrice);
        Console.WriteLine("Pesho:\n{0}", pesho.Payments[0].ProductPrice);
    }
开发者ID:ScreeM92,项目名称:Software-University,代码行数:41,代码来源:Test.cs

示例4: Main

        static void Main()
        {
            Customer lili = new Customer(
                "Lili",
                "Kalapova",
                "Bonin",
                1234567,
                "Plovdiv",
                "4567456",
                "[email protected]",
                new List<Payment>() { new Payment("Lenovo laptop", 850) },
                CustomerType.OneTime);

            Customer gosho = new Customer(
                "Gosho",
                "Kostadinov",
                "Kalapov",
                9876543,
                "Luisville",
                "09017654",
                "[email protected]",
                new List<Payment>() { new Payment("Calculator", 50), new Payment("Mouse Pad", 13), new Payment("Mic", 6) },
                CustomerType.Regular);

            Customer emo = new Customer(
                "Emil",
                "Georgiev",
                "Georgiev",
                5454590,
                "Sofia",
                "08983334",
                "[email protected]",
                new List<Payment>() { new Payment("Server", 2850) },
                CustomerType.Golden);

            var liliCopy = lili;
            lili.Payments.Add(new Payment("mouse", 12));
            lili.LastName = "kalapova-bonin";
            Console.WriteLine(lili);
            Console.WriteLine(liliCopy);
            Console.WriteLine(liliCopy == lili);
            Console.WriteLine(lili.Equals(liliCopy));

            var liliClone = (Customer)lili.Clone();
            Console.WriteLine(lili == gosho);
            Console.WriteLine(lili == liliClone);
            Console.WriteLine(lili == liliCopy);

            Console.WriteLine(lili.CompareTo(gosho));
            Console.WriteLine(emo.CompareTo(lili));
            Console.WriteLine(lili.CompareTo(liliClone));

        }
开发者ID:ScreeM92,项目名称:Software-University,代码行数:53,代码来源:CustomerMain.cs

示例5: Main

        public static void Main()
        {
            Customer rado = new Customer("Rado", "Radov", "Radov", 9043367759, "Radovo", "0888696969", "[email protected]", CustomerType.Golden, new List<Payment>());
            Customer radoCloned = (Customer) rado.Clone();
            Console.WriteLine(rado.Equals(radoCloned)); // Should be true

            radoCloned.Id = 4356345563;
            radoCloned.Payments.Add(new Payment("ProductName", 43543643));
            Console.WriteLine(rado.Equals(radoCloned)); // Should be false

            Console.WriteLine(rado.CompareTo(radoCloned) > 0); // The name is the same but the ID of rado > of ID radoCloned
        }
开发者ID:rvmladenov,项目名称:Soft-Uni,代码行数:12,代码来源:RunProblem.cs

示例6: TestEquals

        public void TestEquals()
        {
            var customer = new Customer();
            var customer2 = customer;
            var clone = customer.Clone();

            Assert.IsTrue(customer.Equals(customer2));
            Assert.IsTrue(customer2.Equals(customer));
            Assert.IsFalse(customer.Equals(new Customer()));
            Assert.IsFalse(new Customer().Equals(customer));
            Assert.IsTrue(customer.Equals(clone));
            Assert.IsTrue(clone.Equals(customer));
        }
开发者ID:eithery,项目名称:core,代码行数:13,代码来源:PersistentObjectTest.cs

示例7: TestClone

        public void TestClone()
        {
            var customer = new Customer();
            var clone = customer.Clone();

            Assert.IsFalse(customer == clone);
            Assert.AreNotSame(customer, clone);
            Assert.AreEqual(customer, clone);
            Assert.IsTrue(customer.Equals(clone));
            Assert.AreEqual(customer.GetHashCode(), clone.GetHashCode());
            Assert.IsInstanceOf<Customer>(clone);
            Assert.AreEqual(customer.Id, ((IPersistentObject)clone).Id);
        }
开发者ID:eithery,项目名称:core,代码行数:13,代码来源:PersistentObjectTest.cs

示例8: TestClone

        public void TestClone()
        {
            var customer = new Customer();
            var clone = customer.Clone();

            Assert.AreEqual(customer.Id, ((IPersistentObject)clone).Id);
            Assert.AreEqual(customer.IsNew, ((IVolatilePersistentObject)clone).IsNew);
            Assert.AreEqual(customer.IsDeleted, ((IVolatilePersistentObject)clone).IsDeleted);
            Assert.AreEqual(customer.Created, ((ICreatable)clone).Created);
            Assert.AreEqual(customer.CreatedBy, ((ICreatable)clone).CreatedBy);
            Assert.AreEqual(customer.Modified, ((IModifiable)clone).Modified);
            Assert.AreEqual(customer.ModifiedBy, ((IModifiable)clone).ModifiedBy);
            Assert.AreEqual(customer.Version, ((DomainObjectBase)clone).Version);
        }
开发者ID:eithery,项目名称:core,代码行数:14,代码来源:DomainObjectBaseTest.cs

示例9: Main

    static void Main()
    {
        Customer first = new Customer("Gosho", "Goshev", "Todorov", "20", "Sofia", "0892323", "[email protected]",
                        new List<Payment>(), CustomerType.Diamond);

        Customer second = new Customer("Gosho", "Goshev", "Todorov", "20", "Sofia", "0892323", "[email protected]", 
                        new List<Payment>(), CustomerType.Diamond);

        Customer third = new Customer("Gosho", "Goshev", "Todoro", "20", "Sofia", "0892323", "[email protected]",
                        new List<Payment>(), CustomerType.Diamond);

        Customer fourth = (Customer)first.Clone();

        Console.WriteLine(first == third);
        Console.WriteLine(first == fourth);
        Console.WriteLine(Object.ReferenceEquals(first, fourth));
    }
开发者ID:shnogeorgiev,项目名称:Software-University-Courses,代码行数:17,代码来源:CustomerDemo.cs

示例10: Main

        public static void Main()
        {
            Customer c1 = new Customer("Stefan", "Canev", "Ivanov", "8712929211", "Krasna Polqna 11, Sofia",
                "0882737632", "[email protected]", CustomerType.Regular);

            c1.Payments.Add(new Payment("Verizon", 11.90m));

            Customer c2 = c1.Clone();

            //c2.Payments.Clear(); // doesn`t clear c1`s payments - we`ve got a deep copy
            c2.Payments.Add(new Payment("Dedepof", 90.00m));
            //c1.Payments.Clear();
            c1.Payments[0].Price = 12345.6m;

            foreach (var payment in c1.Payments)
            {
                Console.WriteLine(payment);
            }

            foreach (var payment in c2.Payments)
            {
                Console.WriteLine(payment);
            }

            // Testing IComparable implementation
            Customer customer1 = new Customer("Stefan", "Canev", "Ivanov", "8712929211", "Krasna Polqna 11, Sofia",
                "0882737632", "[email protected]", CustomerType.Regular);
            Customer customer2 = new Customer("Ivan", "Dobrev", "Zlatinov", "1119021121", "Krasna Polqna 11, Sofia",
                "0882737632", "[email protected]", CustomerType.Regular);
            Customer customer3 = new Customer("Stefan", "Canev", "Ivanov", "1123411223", "Krasna Polqna 11, Sofia",
                "0882737632", "[email protected]", CustomerType.Regular);

            List<Customer> customers = new List<Customer>();

            customers.Add(customer1);
            customers.Add(customer2);
            customers.Add(customer3);
            
            customers.Sort();

            foreach (var customer in customers)
            {
                Console.WriteLine(customer);
            }
        }
开发者ID:Vallerious,项目名称:OOP-Homeworks,代码行数:45,代码来源:Tester.cs

示例11: Main

        static void Main()
        {
            Payment smartTv = new Payment("Sony Bravia", 1500);

            var customer1 = new Customer(
                "Ivan",
                "Angelov",
                "Ivanov",
                8811056253,
                "Sofia, Obelq bl. 125",
                0899963125,
                "[email protected]",
                CustomerType.OneTime,
                smartTv);

            var customer2 = customer1.Clone() as Customer;
            customer2.FirstName = "Georgi";
            customer2.MiddleName = "Petrov";
            customer2.LastName = "Georgiev";
            customer2.Id = 9105074815;

            Console.WriteLine(customer1);
            Console.WriteLine(customer2);
            Console.WriteLine(customer1 == customer2);

            var customer3 = new Customer(
                "Dimitar",
                "Rangelov",
                "Dimitrov",
                9204261459,
                "Burgas, Slavejkov bl. 68",
                0888478125,
                "[email protected]",
                CustomerType.Diamond,
                new Payment("Vafla Borovetz", 0.25));

            var customer4 = customer3.Clone() as Customer;
            customer4.Id = 7810100663;

            var customers = new List<Customer> { customer1, customer2, customer3, customer4 };

            customers.Sort();
            Console.WriteLine(string.Join("\n", customers));
        }
开发者ID:bulgariamitko,项目名称:SoftUniHomeWordsAndMore,代码行数:44,代码来源:Program.cs

示例12: Main

        public static void Main()
        {
            Customer petko = new Customer("Petko", "Ivanov", "Petkov", "Sofia", "659497", "08886967", "[email protected]", CustomerType.Regular);
            Customer ivan = new Customer("Ivan", "Ivanov", "Ivanov", "Sofia", "865493", "088899635", "[email protected]", CustomerType.OneTime);
            Console.WriteLine(ivan == petko);
            Console.WriteLine(ivan != petko);
            Console.WriteLine();

            List<Customer> customers = new List<Customer> { petko, ivan, petko, ivan };
            customers.Sort();
            customers.ForEach(Console.WriteLine);
            Console.WriteLine();

            Customer petkoCloning = petko.Clone();
            petkoCloning.FirstName = "PetkoNumber2";
            petkoCloning.CustomerType = CustomerType.Golden;
            Console.WriteLine(petko);
            Console.WriteLine(petkoCloning);
        }
开发者ID:reminchev,项目名称:SoftUni-Projects,代码行数:19,代码来源:Test.cs

示例13: Main

        static void Main()
        {
            //List<Payment> payments = new List<Payment>();
            //payments.Add(new Payment("Vafli", 23));
            //payments.Add(new Payment("Shokolad", 123));
            //payments.Add(new Payment("Banica", 11));
            //Customer customer1 = new Customer("Ivan", "Angelov", "Ivanov", "1", "Ulica Sezam 32", "088835596268", "[email protected]", payments, CustomerType.Golden);
            //Customer customer2 = new Customer("Ivan", "Angelov", "Ivanov", "2", "Ulica Sezam 23", "088875564262", "[email protected]", payments, CustomerType.Regular);
            //Customer customer3 = customer1;

            //Console.WriteLine(customer1.Equals(customer2));
            //Console.WriteLine(customer1.Equals(customer3));

            //Console.WriteLine(customer2);

            //Console.WriteLine(customer1.CompareTo(customer2));
            //Console.WriteLine(customer1.CompareTo(customer3));

            //Customer deepCopy = (Customer)customer2.Clone();
            //customer2.FirstName = "Zhan";
            //Console.WriteLine(deepCopy);
            //Console.WriteLine(customer2);
            List<Payment> payments = new List<Payment>()
            {
                new Payment("book", 24),
                new Payment("phone", 243),
                new Payment("tablet", 500),
                new Payment("phone", 234),
                new Payment("tablet", 500)
            };

            var pesho = new Customer("Petar", "Ivanov", "Mitrev", "12312412", "Ulica Sezam", "241134134", "[email protected]", payments, CustomerType.Diamond);



            Console.WriteLine("Pesho before cloning:\n{0}", pesho);
            Console.WriteLine();
            Customer cloning = (Customer)pesho.Clone();

            cloning.Payments[1].Price = 2001;

            Console.WriteLine("Pesho after cloninig:\n{0}", cloning);
        }
开发者ID:zhanivanov,项目名称:OOP_September_Homeworks,代码行数:43,代码来源:MainProgramClass.cs

示例14: Main

        static void Main(string[] args)
        {
            var st1 = new Customer("Pesho", "Peshov", "Peshov", "9087654323");
            var st3 = new Customer("Kolio", "Peshov", "Peshov", "9087654323");
            var st2 = (Customer)st3.Clone();
            st2.FirstName = "Typanar";
            var st4 = st2.Clone();
            st4.ID = "098872356354";

            var p = new Payment();

            Console.WriteLine(st1.Equals(st1));

            var customers = new List<Customer>(){
                st1,st2,st3,st4
            };
            customers.Sort();

            customers.ForEach(x=>Console.WriteLine(x));
        }
开发者ID:Kaloyan-kasskata-Anastasov,项目名称:All-HomeWorks-SoftwareUniversity-TelerikAcademy,代码行数:20,代码来源:Program.cs

示例15: Main

        public static void Main()
        {
            var customerOne = new Customer("Goshko", "Goshkov", "Georgiev", "1234567890", CustomerType.Golden);
            var customerTwo = customerOne.Clone();
            Console.WriteLine("Customers are one and the same object in memory: {0}", ReferenceEquals(customerOne, customerTwo));
            Console.WriteLine("Both students are equal (with same values): {0}\n", customerOne.Equals(customerTwo));
            customerTwo.MiddleName = "Petranov";
            customerTwo.MobilePhone = "0888 / 000 000";
            customerOne.Email = "[email protected]";
            var customerThree = new Customer("Pencho", "Petkov", "Grozdanov", "0987654321", CustomerType.Diamond);
            customerThree.AddListOfPayments(
                new List<Payment>() { new Payment("iPad", 1000000.0m), new Payment("Nokia", 100.0m) });

            var customers = new List<Customer>() { customerOne, customerTwo, customerThree };
            customers.Sort();
            foreach (var customer in customers)
            {
                Console.WriteLine(customer);
            }
        }
开发者ID:tormibg,项目名称:SoftUni-1,代码行数:20,代码来源:CustomerTest.cs


注:本文中的Customer.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。