If I have a nested class, does anything from the owning class exist in the owned class?
for example:
public class OwningClass
{
int randomVariable = 1;
public void MakingMethod()
{
OwnedClass owned = new OwnedClass();
owned.SomeMethod();
}
private class OwnedClass
{
public void SomeMethod()
{
// Is anything from OwningClass available here?
}
}
}
Anything "static" from the owning class is available in your nested class.
If you have an instance of the owning class in some method of the inner class, you may also access its private members.
The only thing a nested class changes with respect to it's parent class is accessibility. The nested class can access private members of the containing type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With