ASP.NET Reflection get typeof current object
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 i开发者_如何学Got possible to get the PropertyInfo typeof for an object from within the object without hard coding the object type or using a generic?
You can use this.GetType()
in the base and receive the Type
of the derived class.
精彩评论