Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // var trialPerson = new Person {Name="trial", DateOfBirth= new DateTime(1982,05,02)};
            // trialPerson.WriteToConsole();

            var harry = new Person {
                Name = "Harry"
            };
            var mary = new Person {
                Name = "Mary"
            };
            var jill = new Person {
                Name = "Jill"
            };

            //call instance medhod
            var baby1 = mary.ProcreateWtih(harry);

            //call static method
            var baby2 = Person.Procreate(harry, jill);

            //call an operator
            var baby3 = harry * mary;

            WriteLine($"{harry.Name} has {harry.Children.Count} children's");
            WriteLine($"{mary.Name} has {mary.Children.Count} children's");
            WriteLine($"{jill.Name} has {jill.Children.Count} children's");
            WriteLine($"Harry's first child name is {harry.Children[0].Name}");

            // call local function
            WriteLine($"5! is {Person.Factorial(5)}");