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

namespace ConsoleApplication1
{
    class xiushifu //用CLASS来创建一个类
    {
        public int a;//访问不受限制;
        private int b;//私有的,只有包含此字段的类可以访问;
        protected int c;//仅在当前类和派生类中可以访问;
        internal int d;//仅在当前命名空间里可以访问;
        int e;//没有修饰符,默认是私有的字段:
        public int B//创建一个属性,记住和方法的不同之处是属性的签名后面没有括号,而方法是有括号的
        {
            get { return this.b; }
             protected set { this.b = value; }//如果属性中没有SET,说明此属性是只读属性,
        }

    }
    class xiushifu2 : xiushifu
    {
        public int x;
        public int b()//创建一个方法,记住与属性的区别哟
        {
           base.B=123;
           return base.B;
       
        }


   
    }
}
=============

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            xiushifu2 x = new xiushifu2();
            Console.WriteLine(x.b());
        
        }

    }

}

posted on 2008-12-16 23:47  xf雪儿  阅读(190)  评论(0编辑  收藏  举报