假设我有一个抽象基类:
public abstract class BaseClass
{
private MyObject myObject;
protected MyObject PropA
{
get
{
if(myObject == null) this.myObject = new MyObject();
return this.myObject;
}
}
}
Run Code Online (Sandbox Code Playgroud)
...在我的派生类之一中,我想将受保护的基类属性设为PropA
public。在这种情况下使用new
修饰符是否正确?
public class DerivedClass : BaseClass
{
public new MyObject PropA
{
get
{
return base.PropA;
}
}
}
Run Code Online (Sandbox Code Playgroud)