第2節5属性2

1694 ワード

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


//Red Gate's Reflector  
namespace _5 2
{
    class Program
    {
        static void Main(string[] args)
        {
            //Person5 p = new Person5();
            //p.Age = 30;
            //Console.WriteLine(p.Age);

            //Person6 p = new Person6();
            //p.IncAge();
            //p.IncAge();
            //Console.WriteLine(" {0}",p.Age);

            Person7 p = new Person7();
            p.Age = 30;
            Console.WriteLine(p.Age);

            
            Console.ReadKey();
        }
    }

    class Person7 
    {
        public int Age
        {
            get;
            set;
        }
        public string Name
        {
            get;
            set;
        }
    }

    class Person6
    {
        private int age;
        public int Age // , 
        {
            get { return age; }
        }
        public void IncAge() 
        {
            age++;
        }
    }

    class Person5 
    {
        private int age;
        public int Age {
            set {
                this.Age = value; // , , value this.Age ,
                // this.Age , 
            }
            get {
                return this.Age;
            }
        }
    }
}