<分区>
如果我有 ObjectA,它有一个私有(private)方法 GetPrice()
并且还有一个相同类型的“父”字段,为什么我可以调用 GetPrice()
在子实例中的父实例上?
例子:
private decimal GetPrice()
{
ObjectA parent = Parent;
if(parent != null)
{
return parent.GetPrice(); // Why is this OK?
}
return 0;
}