If I have ObjectA, and it has a private method GetPrice()
and also has a "parent" field of the same type, why am I able to call GetPrice()
on the parent instance from within the child instance?
Example:
private decimal GetPrice()
{
ObjectA parent = Parent;
if(parent != null)
{
return parent.GetPrice(); // Why is this OK?
}
return 0;
}
Because private means "not accessible to other types", not "not accessible to other instances".