Exemplo n.º 1
0
        /*
         * int ,decimal,float,enum,double,bool are 'value types'
         * array, class, interface are 'reference types'
         */
        static void Main(string[] args)
        {
            /*  int number1 = 10;
             * int number2 = 30;
             * number1 = number2;//number1=30
             * number2 = 65;
             * Console.WriteLine(number1);//number1=30
             *
             * int[] numbers1 = new int[] { 10, 20, 30 };
             * int[] numbers2 = new int[] { 100, 200, 300 };
             * numbers1 = numbers2;
             * numbers2[0] = 999;
             * Console.WriteLine(numbers1[0]);
             */

            Person person1 = new Person();
            Person person2 = new Person();

            person1.FirstName = "Yasin";
            person2           = person1;

            person1.FirstName = "Özer";
            Console.WriteLine(person2.FirstName);

            Customer customer = new Customer();

            customer.FirstName    = "Osman";
            customer.CreditNumber = "1234567";
            Employee employee = new Employee();

            Person person3 = customer;

            Console.WriteLine(person3.FirstName);


            Console.WriteLine("person3.name : " + person3.FirstName + "customer : " + customer.FirstName + ((Customer)person3).CreditNumber);
            Console.WriteLine("-------------------------------------");
            PersonManager personManager = new PersonManager();

            personManager.Add(employee);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            int number1 = 10;
            int number2 = 30;

            number1 = number2;
            number2 = 65;

            //number1 ?? => 30

            int[] numbers1 = new int[] { 10, 20, 30 };
            int[] numbers2 = new int[] { 100, 200, 300 };

            numbers1    = numbers2;
            numbers2[0] = 999;

            //numbers1[0]   ??  => 999

            /*
             * Value Types => Değer Tipler
             * int
             * decimal
             * float
             * double
             * bool
             * enum
             *
             * Reference Types => Referans Tipler
             * Array
             * Class
             * Interface
             */

            Person person1 = new Person();
            Person person2 = new Person();

            person1.FirstName = "Engin";

            person2           = person1;
            person1.FirstName = "Derin";

            Console.WriteLine(person2.FirstName); // Derin

            Customer customer = new Customer();

            customer.FirstName        = "Salih";
            customer.CreditCardNumber = "223456487";

            Employee employee = new Employee();

            employee.FirstName = "Veli";

            Person person3 = customer;

            customer.FirstName = "Ahmet";

            Console.WriteLine(person3.FirstName);                    // Salih
            Console.WriteLine(((Customer)person3).CreditCardNumber); // 223456487

            PersonManager personManager = new PersonManager();

            personManager.Add(employee); // Veli
        }