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