I hope the question makes sense, anyways. I’m looking to know if in VB.NET, when we call an object’s constructor, is there some kind of a reference that points back to the caller?
I’m interested because of a corner case where I want the object being created to first be able to validate the existence of some data in the caller before it allows itself to be created. If this validation fails, I plan on throwing an exception. This corner case will never happen at runtime unless the object being created is used improperly by a programmer. The object being created is not inheriting the object I want it to validate, so I can’t do anything with the MyBase qualifier.
It’s bit of a “future-proofing” issue that I have a (bad) habit of doing. Not critical — I can always leave stern comments behind as a last resort. Wanted to know if this was possible.
There isn’t a built-in reference to the caller, but the caller could pass a reference to itself as a parameter to the constructor.