Example #1
0
        static void Main(string[] args)
        {
            Person p = new Person {
                Firstname = "Tom", Lastname = "Bill"
            };                                                                          // инициализатор объекта

            p.Display();

            p = new Employee {
                Firstname = "Denis", Lastname = "Rich"
            };                                                                          // инициализатор объекта
            p.Display();

            Person2 p2 = new Person2 {
                Firstname2 = "Tommy", Lastname2 = "Billi"
            };

            p2 = new Employee2 {
                Firstname2 = "Tom", Lastname2 = "Bill", Company = "Microsoft"
            };
        }
Example #2
0
        static void Main(string[] args)
        {
            var superHero = new SuperHero();

            superHero.Name = "Batman";
            superHero.Age  = 30;

            var superHero2 = new SuperHero {
                Name = "Spiderman",
                Age  = 20
            };

            Console.WriteLine("My super hero name is {0}", superHero.Name);


            Person person = new Person {
                FirstName = "John", LastName = "Doe"
            };

            person.Display();

            var employee = new Employee {
                FirstName = "Vasja", LastName = "Pupkin"
            };

            //employee.Age = 21;
            employee.Display();
            employee.Display2();

            Person employedPerson = new Employee {
                FirstName = "Billy", LastName = "Gates", Id = 7
            };                                                                                      // var type Person can create object type Employee

            employedPerson.Display();

            Console.Read();
        }