输出的为X= 1 ,Y = 0;

 public class A
    {
        public A()
        {
         PrintFields();
        }
        public virtual void PrintFields()
        {}
    }

    public class B : A
    {
        int x = 1;
        int y;
        public B()
        {
            y = -1;
        }

        public override void PrintFields()
        {
            Console.WriteLine("x={0},y={1}", x, y);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            B b = new B();
            Console.ReadLine();
        }
    }

输出的为X= 1 ,Y = 0;

posted @ 2010-12-03 21:11  双面人3  阅读(140)  评论(0编辑  收藏  举报