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;
        }
    }
}




猜你喜欢

转载自www.cnblogs.com/mlh1421/p/3f45b9cbfa236388678f32a127f9b8a0.html