Why can I call a private method of another instance of the same type outside of that instance? [duplicate]
问题 This question already has answers here : Why and how does C# allow accessing private variables outside the class itself when it's within the same containing class? (3 answers) Closed last year . 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()