C#访问权限
protected 受保护的 类成员的修饰符 在类的内部或者在派生类中访问,不管该类和派生类是不是在同一程序集中x
1
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;
}
}
}19
1
using System;2
namespace app {3
class App {4
public static void Main (string[] args) {5
C c = new C ();6
// B bb = new B ();7
Console.WriteLine (c.getB ());8
}9
}10
class B {11
//protected12
protected int b = 10;13
}14
class C : B {15
public int getB () {16
return this.b;17
}18
}19
}
浙公网安备 33010602011771号