本帖最后由 Shalves 于 2010-06-28 18:23:18 编辑

解决方案 »

  1.   

    我还换了这种写法,结果也是一样。谁指点指点啊,到底该怎样认识get访问器呢。    class Program
        {
            static void Main(string[] args)
            {
                thePlus tp = new thePlus();
                PlusX(tp.X);
            }        public static void PlusX(int value)
            {
                Console.WriteLine("Value is: {0}", value);
                Console.ReadKey();
            }
        }    class thePlus
        {
            private int x;        public int X
            {
                get { return x++; }
            }
        }
      

  2.   

    这个和get访问器没关系。,你将  public static int X中的
    static 去掉,,应该就是1了
      

  3.   

    x++先取值,再自加
    只带有 get 访问器的属性称为只读属性。无法对只读属性赋值。  
    get  访问器都必须在属性体的内部声明。
      

  4.   

    楼主变成, get { return ++x; }
      

  5.   


    +1
    class thePlus
    {
        private int x;
        public int X
        {
            get { return x++; }
        }
    }//效果相当于class thePlus
    {
        private int x;
        public int X
        {
            get 
            {
                int t = x;
                x++; 
                return t;
            }
        }
    }
      

  6.   

    是啊,多谢各位。还有一个问题,我在设置断点调试的时候,鼠标移到X上,也会显示已经+1的结果;这是为何,难道get跟DataReader一样也是顺向流的读取方式?