C#访问权限

protected   受保护的    类成员的修饰符        在类的内部或者在派生类中访问,不管该类和派生类是不是在同一程序集中
using System;
namespace app {
    class App {
        public static void Main (string[] args) {
            C c = new C ();
            // B bb = new B ();
            Console.WriteLine (c.getB ());
        }
    }
    class B {
        //protected
        protected int b = 10;
    }
    class C : B {
        public int getB () {
            return this.b;
        }
    }
}




posted @ 2019-04-12 16:43  liliyou  阅读(211)  评论(0编辑  收藏  举报