2015年11月9日 星期一

C7_99 測試靜態域和非靜態域的區別

using System;
namespace C7_99
{
    public class Count
    {
        public static int count;
        private int number;
        public Count()
        {
            count = count + 1;
            number = count;
        }
        public void show()
        {
            Console.WriteLine("object{0}:count={1}",number,count);
        }
    }
    public class Program
    {
        public static void Main()
        {
            Count a = new Count();
            a.show();
            Console.WriteLine("---------");
            Count b = new Count();
            a.show();
            b.show();
            Console.WriteLine("---------");
            Count c = new Count();
            a.show();
            b.show();
            c.show();
        }
    }
}

沒有留言: