What I'm wondering is if it's possible to (for instance) to walk up the stack frames, checking each calling object to see if matches an interface, and if so extract some data from it.
Yes, I know it's bad practice, I'm wondering if it's possible.
Here, we have added the ref keyword with the input parameter that means when we call this method, the argument must be passed by reference. Then we call the UpdateValue method but while calling, we have to use the ref keyword before the argument name. This is Call by Reference in C# with Value Type.
The this keyword is used to reference the current instance of a class, or an object itself, if you will. It is also used to differentiate between method parameters and class fields if they both have the same name.
"Calling object" is the object that calls the method . – debashish. Jul 2, 2017 at 3:27. The "calling object" is passed implicitly as the first argument (e.g., as "self" in its class definition): object1. method(object2) is the same as method(object1, object2) .
No, there isn't - at least not without using a profiling/debugging API of some description. You can walk the stack to find the calling method, with the caveat that it's really slow and may be inaccurate due to JIT optimisations. That won't tell you what the calling object is though (if indeed there is one).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With