Does a Base Class know it's instanced class?

G

Guest

I would like to have methods in my base class that use reflection against its
derived class.

Is there any way for my base class to access its derived class? It does not
appear to be the case.

If not, how bad (programming practice-wise) is it to have a property in the
base class that references the instanced class? Or via the base class,
instance another object that has a reference to the instanced class.
 
M

Mattias Sjögren

Is there any way for my base class to access its derived class?

Sure, once you have an instance of the derived class. For example,
this.GetType() returns the actual type of the object.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top