Example:
namespace WFA
{
public class A
{
protected int x = 1;
private int y;
}
public class B : A
{
B()
{
x = 2; // can access x, but cannot access y
A a = new A();
a.x = 1; // Error: Cannot access protected member 'WFA.A.x' via a qualifier of type 'WFA.A'; the qualifier must be of type 'WFA.B' (or derived from it)
}
}
Niciun comentariu:
Trimiteți un comentariu