如何从基类查找子类名称?

run-time,在 base class中,如何找到当前的子类名?

67594 次浏览

If you call this.GetType() you'll always get the current runtime type regardless of the base class you're inheriting from.

Get the type of the current object, then its name.

this.GetType().Name

Try this:

Type type = this.GetType().UnderlyingSystemType;
String className = type.Name;