Is it possible to get the name of the property to which the current class is assigned in the class from which it was called?
Let's say I have three classes:
class Parent1 { public Child myName; public void Foo() { myName.Method(); } } class Parent2 { public Child mySecondName; public void Foo() { mySecondName.Method(); } } class Child { public void Method() { Log(__propertyName__); } }
I would like the Log value of myName when Method is called from Parent1 and mySecondName if Method is called from Parent2 .
Is it possible, using reflection, and not by passing names along the line in the argument (I want to use it only for debugging purposes, I don't want to bind this class in any way)
source share