mardi 22 décembre 2015

Reflection to Get `Parent` Object

I'm pretty sure this isn't possible, but thought I'd ask anyways.

Say I have:

public class A
{
    public B BInstance { get; set; }
}

public class B
{
    public Type GetParentType()
    {
        //...
    }
}

Is there any possible way, via reflection, for B's GetParentType to return typeof(A) at runtime?

I know I could simply pass typeof(this) into B when I initialize it on A, I'm just curious.





Aucun commentaire:

Enregistrer un commentaire