Reference to caller object
Is it possible to get a reference to the object that is calling a function inside that function? (Without passing it has a parameter)
Example:
Code:
Interface I
{
void CallerMethod();
void CalledBackMethod();
}
public class A : I
{
public void CallerMethod()
{
B b = new B();
b.CalledMethod();
}
public void CalledBackMethod()
{
//Do something
}
}
public class B
{
public void CalledMethod()
{
I i = GetCallingObject(); //This is what I want!!
i.CalledBackMethod()
}
}
Or is there other ways of doing this?
Thanks!