1
有沒有辦法限制評論中概述的這些類的成員的訪問權限;是否有一個訪問修飾符,它允許繼承類修改c#中父類的成員?
class a
{
int p //should be accessable by b,c, but not by x
}
class b:a
{
int q //should be accessable by c, if it has to by a, but not by x
}
class c:b
{
public int r //obviously accessable by anyone
}
class x
{
c testfunction()
{
c foo=new c();
foo.r=20;
return foo;
}
}
這是比這裏的示例代碼更復雜一點,但我認爲我得到了我的問題。