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