When a field in an instance of a class belongs to another class, can the other class's instance knows the name of the class of which it is a field?
For example,
public class ClassA
{
public void MethodA()
{
... // can an ClassA instance know the name of the class of which it is a field?
}
}
public class ClassB
{
Public ClassA objA;
public void MethodB()
{
objA.MethodA();
}
}
public class ClassC
{
Public ClassA objA;
public void MethodC()
{
objA.MethodA();
}
}
public static void Main(string[] args)
{
ClassB objB = new ClassB();
objB.MethodB();
ClassB objC = new ClassC();
objC.MethodC();
}
When either objB.MethodB()
or objC.MethodC()
calls objA.MethodA()
, inside objA.MethodA()
, can it know the name of the class of which objA
is a field, without having to pass the name of the class as a parameter to objA.MethodA()
? Thanks.