views:

34

answers:

1

I am working on a project where all of our object have a standard base class. We just added some new fields to the database for the tables behind some of the objects e.g. "DateCreated".

I would like to use reflection on the base class' insert method so that when it is called it checks the object to see if it has a property "DateCreated" and if it does sets it to DateTime.Now

The problem I'm having is typeof(this) does not work and I don't know what the type is in the base class obviously.

Is it possible to get the PropertyInfo typeof for an object from within the object without hard coding the object type or using a generic?

A: 

You can use this.GetType() in the base and receive the Type of the derived class.

Anthony Pegram
That did it thank you.
William