コード例 #1
0
        static void useAccessModifiers()
        {
            var person = new PersonDate();

            person.SetBirthdate(new DateTime(1982, 1, 1));
            Console.WriteLine(person.GetBirthdate());
        }
コード例 #2
0
        static void useProperties()
        {
            var person = new PersonDate(new DateTime(1982, 1, 1));

            Console.WriteLine(person.Birthdate);
            //use "person.Birthdate"
            //to get birthdate variable using the {get; set;} in the property
            Console.WriteLine(person.Age);

            //person.Birthdate = new DateTime(1999, 2, 2);
            //"person.Birthdate = ***"
            //cannot be used because the "set" in {get; private set;}
            ///is set to private and can only be used in the constructor
        }