コード例 #1
0
        public InheritanceCompositionTest()
        {
            var inheritancePerson = new NaturalPerson
            {
                Name        = "Denis",
                DateOfBirth = DateTime.Now,
                Nif         = "32165498765"
            };

            var compositionPerson = new NaturalPerson2
            {
                Person = new Person
                {
                    Name        = "Denis",
                    DateOfBirth = DateTime.Now,
                },
                Nif = "32165498765"
            };

            var inheritanceName = inheritancePerson.Name;
            var compositionName = compositionPerson.Person.Name;
        }
コード例 #2
0
        public InheritanceCompositionTests()
        {
            var personInheritance = new NaturalPerson
            {
                Name        = "João",
                DateOfBirth = DateTime.Now,
                Cpf         = "32165498765"
            };

            var personComposition = new NaturalPerson2
            {
                Person = new Person
                {
                    Name        = "João",
                    DateOfBirth = DateTime.Now
                },
                Cpf = "32165498765"
            };

            var nameInheritance = personInheritance.Name;
            var nameComposition = personComposition.Person.Name;
        }