I have the following scenario in C#
public class classA
{
public int fieldA = 1;
public classA()
{
classB b=new classB();
b.Execute();
}
}
public class classB
{
public Execute()
{
//I can get the type of classA using
FieldInfo fi = stackTrace.GetFrame(1).GetMethod().DeclaringType
}
}
The question is how do I get the reference of classA that invoked the Execute in the instance of classB?
I tried using reflection but could not find any way to do it.
Any help would be much appreciated