chsalvia
asked on
Get Reference to Parent Class
If you have a nested class inside a parent class, the 'this' keyword will of course refer to an instance of the nested class when used inside the nested class. But is there any way to get a reference to an instance of the parent class, without passing one over to the constructor of the nested class?
public class Parent
{
class Nested
{
void doSomething()
{
Parent p = this; // <--- doesn't work because 'this' refers to an instance of Nested
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.