I have a nested class within an outer class and from within the inner class I would like to get the name of the outer class via reflection at runtime.
public abstract class OuterClass // will be extended by children
{
protected class InnerClass // will also be extended
{
public virtual void InnerMethod()
{
string nameOfOuterClassChildType = ?;
}
}
}
Is this possible in c#?
Edit: I should add, that I want to use reflection and get the name from a child class which extens from OuterClass, which is the reason, I don't know the concrete type at compile time.
Something like this should parse out the name of the outer class:
Or, as @LasseVKarlsen proposed,
...which is actually a better answer.