The protected modifier must be noted that the protected recognized by the sub-class belongs to itself and is irrelevant to others.
A parent, B child, c child
Regardless of how B and C modify the protected volume, B and c do not affect each other, for example:
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Namespace consoleapplication1
{
Class Program
{
Static void main (string [] ARGs)
{
B = new B ();
C = new C ();
//////////////////////
No matter which of the following values is set first, the results will not change.
C. setv ("C ");
B. setv ("B ");
////////////////////////
Console. Write (C. cv );
Console. Write (B. BV );
}
}
Class
{
Protected string S;
}
Class B:
{
Internal void setv (string)
{
S =;
}
Public String BV
{
Get {return s ;}
}
}
Class C:
{
Internal void setv (string)
{
S =;
}
Public String CV
{
Get {return s ;}
}
}
}