class Program
{
class TestA
{
protected string protectedStringA;
}
class TestB : TestA
{
string StringTestB()
{
return protectedStringA;
}
}
class TestC : TestB
{
string StringTestC()
{
return protectedStringA;
}
}
static void Main(string[] args)
{
}
}
作爲每this鏈路保護所述的定義是「的類型或成員只能由代碼在從衍生的一類在同一類或結構,或被訪問那個類「。這裏的類TestC不是從TestA派生的。但是protectedStringA仍然可以訪問。 類的確切含義是從該類派生而來的?保護訪問修飾符含義衍生
TestC從派生自TestA的TestB派生而來,TestC是TestA。 – 2014-12-02 22:47:05