是否可以授予对基类设置器的私有访问权限,并且只能从继承类中使用它,就像受保护的关键字一样?
public class MyDerivedClass : MyBaseClass
{
public MyDerivedClass()
{
// Want to allow MyProperty to be set from this class but not
// set publically
public MyProperty = "abc";
}
}
public class MyBaseClass
{
public string MyProperty { get; private set; }
}