Пример #1
0
        private static void LoadPersons(PersonManager manager)
        {
            IList <Person> persons = new List <Person>
            {
                new Person
                {
                    OIB     = "01234567901",
                    Name    = "Karlo",
                    Surname = "Fabijanic",
                    Phone   = "012",
                    Email   = "*****@*****.**"
                },

                new Person
                {
                    OIB     = "01234567911",
                    Name    = "Karlo",
                    Surname = "Fabijanic",
                    Phone   = "0123",
                    Email   = "*****@*****.**"
                },

                new Person
                {
                    OIB     = "0123567921",
                    Name    = "Newbie",
                    Surname = "Bie",
                    Phone   = "01234",
                    Email   = "*****@*****.**"
                },
                new Person
                {
                    OIB     = "01234567931",
                    Name    = "Getti",
                    Surname = "",
                    Phone   = "1012",
                    Email   = "*****@*****.**"
                },

                new Person
                {
                    OIB     = "012345678902",
                    Name    = "Daniel",
                    Surname = "",
                    Phone   = "",
                    Email   = ""
                }
            };

            manager.SavePersons(persons);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Person person1 = new Person();



            Customer customer = new Customer();

            customer.Id               = 1;
            customer.FirstName        = "Gokhan";
            customer.LastName         = "Goy";
            customer.CreditCardNumber = "12345678910";

            Employee employee = new Employee();

            // employee = customer; employee object couldn't hold a reference
            // for a different class in this case Customer
            //employee = person1; Child Class cannot hold a reference for its base or parent class

            person1           = customer;
            person1.FirstName = "Gokhan1";
            //Console.WriteLine(((Customer)person1).ToString());
            Console.WriteLine(customer.FirstName);

            Person person2 = new Person();

            person2.FirstName = "Gokhan";
            person2.LastName  = "Goy";
            person2.Age       = 26;
            person2.Id        = 1;

            PersonManager personManager = new PersonManager();

            personManager.Add(employee); //Output : null
            personManager.Add(customer); //Output : Gokhan1 Goy
            personManager.Add(person2);  //Output : Gokhan Goy
        }