How to find the child class name from base class?
At run-time
, inside base class
, how to find the current child class name ?
Get the type of the current object, then its name.
this.GetType().Name
Try this:
Type type = this.GetType().UnderlyingSystemType;
String className = type.Name;
If you call this.GetType()
you'll always get the current runtime type regardless of the base class you're inheriting from.